comparison src/g23m-fad/ppp/ppp_onas.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
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This modul is part of the entity PPP and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (ONA-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef PPP_ONAS_C
24 #define PPP_ONAS_C
25 #endif /* !PPP_ONAS_C */
26
27 #define ENTITY_PPP
28
29 /*==== INCLUDES =============================================================*/
30
31 #include "typedefs.h" /* to get Condat data types */
32 #include "vsi.h" /* to get a lot of macros */
33 #include "macdef.h" /* to get a lot of macros */
34 #include "custom.h" /* to get a lot of macros */
35 #include "gsm.h" /* to get a lot of macros */
36 #include "cnf_ppp.h" /* to get cnf-definitions */
37 #include "mon_ppp.h" /* to get mon-definitions */
38 #include "prim.h" /* to get the definitions of used SAP and directions */
39 #include "dti.h" /* to get the DTILIB definitions */
40 #include "ppp.h" /* to get the global entity definitions */
41
42 #include "ppp_arbf.h" /* to get the arb function definitions */
43 #include "ppp_ftxs.h" /* to get the ftx signal interface */
44 #include "ppp_lcps.h" /* to get the lcp signal interface */
45 #include "ppp_ncps.h" /* to get the ncp signal interface */
46 #include "ppp_onaf.h" /* to get the ona function definitions */
47 #include "ppp_rts.h" /* to get the rt signal interface */
48
49 /*==== CONST ================================================================*/
50
51 /*==== LOCAL VARS ===========================================================*/
52
53 /*==== PRIVATE FUNCTIONS ====================================================*/
54
55 /*==== PUBLIC FUNCTIONS =====================================================*/
56
57
58
59 /*
60 +------------------------------------------------------------------------------
61 | Function : sig_any_ona_ruc_ind
62 +------------------------------------------------------------------------------
63 | Description : Handles the internal signal SIG_ANY_ONA_RUC_IND
64 |
65 | Parameters : ptype - type of packet
66 | packet - pointer to a generic data descriptor
67 |
68 +------------------------------------------------------------------------------
69 */
70 GLOBAL void sig_any_ona_ruc_ind (USHORT ptype, T_desc2* packet)
71 {
72 UBYTE index;
73 TRACE_ISIG( "sig_any_ona_ruc_ind" );
74
75 /*
76 * determine ONA-instance
77 */
78 ona_get_inst_index(ptype, &index);
79 ppp_data->ona = & ppp_data->ona_base[index];
80
81 switch( GET_STATE( PPP_SERVICE_ONA ) )
82 {
83 case ONA_CLOSING:
84 case ONA_REQ_SENT:
85 case ONA_ACK_RCVD:
86 case ONA_ACK_SENT:
87 case ONA_OPENED:
88 /*
89 * send code reject
90 */
91 sig_any_ftx_packet_req(ptype, packet); /* scj */
92 break;
93 default:
94 TRACE_ERROR( "SIG_ANY_ONA_RUC_IND unexpected" );
95 arb_discard_packet(packet);
96 break;
97 }
98 } /* sig_any_ona_ruc_ind() */
99
100
101
102 /*
103 +------------------------------------------------------------------------------
104 | Function : sig_any_ona_open_ind
105 +------------------------------------------------------------------------------
106 | Description : Handles the internal signal SIG_ANY_ONA_OPEN_IND
107 |
108 | Parameters : ptype - type of packet
109 | packet - pointer to a generic data descriptor
110 |
111 +------------------------------------------------------------------------------
112 */
113 GLOBAL void sig_any_ona_open_ind (USHORT ptype, T_desc2* packet)
114 {
115 UBYTE index;
116 TRACE_ISIG( "sig_any_ona_open_ind" );
117
118 /*
119 * determine ONA-instance
120 */
121 ona_get_inst_index(ptype, &index);
122 ppp_data->ona = & ppp_data->ona_base[index];
123
124 switch( GET_STATE( PPP_SERVICE_ONA ) )
125 {
126 case ONA_OPENED:
127 case ONA_CLOSED:
128 case ONA_CLOSING:
129 case ONA_REQ_SENT:
130 case ONA_ACK_RCVD:
131 case ONA_ACK_SENT:
132 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
133 /*
134 * reset counters
135 */
136 ppp_data->ona->restarts = ppp_data->mc;
137 ppp_data->ona->failures = ppp_data->mf;
138 ppp_data->ona->loops = ppp_data->mc + 1;
139 /*
140 * send configure request
141 */
142 sig_any_ftx_packet_req(ptype, packet); /* scr */
143 /*
144 * start timer
145 */
146 if(ppp_data->ona->restarts > 0)
147 ppp_data->ona->restarts--;
148 sig_any_rt_rrt_req();
149 break;
150 default:
151 TRACE_ERROR( "SIG_ANY_ONA_OPEN_IND unexpected" );
152 arb_discard_packet(packet);
153 break;
154 }
155 } /* sig_any_ona_open_ind() */
156
157
158
159 /*
160 +------------------------------------------------------------------------------
161 | Function : sig_any_ona_down_ind
162 +------------------------------------------------------------------------------
163 | Description : Handles the internal signal SIG_ANY_ONA_DOWN_IND
164 |
165 | Parameters : ptype - type of packet
166 |
167 +------------------------------------------------------------------------------
168 */
169 GLOBAL void sig_any_ona_down_ind (USHORT ptype)
170 {
171 UBYTE index;
172 TRACE_ISIG( "sig_any_ona_down_ind" );
173
174 /*
175 * determine ONA-instance
176 */
177 ona_get_inst_index(ptype, &index);
178 ppp_data->ona = & ppp_data->ona_base[index];
179
180 switch( GET_STATE( PPP_SERVICE_ONA ) )
181 {
182 case ONA_CLOSED:
183 case ONA_OPENED:
184 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
185 break;
186 case ONA_CLOSING:
187 case ONA_REQ_SENT:
188 case ONA_ACK_RCVD:
189 case ONA_ACK_SENT:
190 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
191 /*
192 * stop timer
193 */
194 sig_any_rt_srt_req();
195 break;
196 default:
197 TRACE_ERROR( "SIG_ANY_ONA_DOWN_IND unexpected" );
198 break;
199 }
200 } /* sig_any_ona_down_ind() */
201
202
203
204 /*
205 +------------------------------------------------------------------------------
206 | Function : sig_any_ona_close_ind
207 +------------------------------------------------------------------------------
208 | Description : Handles the internal signal SIG_ANY_ONA_CLOSE_IND
209 |
210 | Parameters : ptype - type of packet
211 | packet - pointer to a generic data descriptor
212 |
213 +------------------------------------------------------------------------------
214 */
215 GLOBAL void sig_any_ona_close_ind (USHORT ptype, T_desc2* packet)
216 {
217 UBYTE index;
218 TRACE_ISIG( "sig_any_ona_close_ind" );
219
220 /*
221 * determine ONA-instance
222 */
223 ona_get_inst_index(ptype, &index);
224 ppp_data->ona = & ppp_data->ona_base[index];
225
226 switch( GET_STATE( PPP_SERVICE_ONA ) )
227 {
228 case ONA_CLOSED:
229 arb_discard_packet(packet);
230 /*
231 * send This-Layer-Finished signal
232 */
233 if (ptype EQ DTI_PID_LCP)
234 {
235 sig_ona_lcp_tlf_req();
236 }
237 else if (ptype EQ DTI_PID_IPCP)
238 {
239 sig_ona_ncp_tlf_req();
240 }
241 break;
242 case ONA_CLOSING:
243 arb_discard_packet(packet);
244 break;
245 case ONA_OPENED:
246 case ONA_REQ_SENT:
247 case ONA_ACK_RCVD:
248 case ONA_ACK_SENT:
249 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
250 /*
251 * reset counter
252 */
253 ppp_data->ona->restarts = ppp_data->mt;
254 /*
255 * send terminate request
256 */
257 sig_any_ftx_packet_req(ptype, packet); /* str */
258 /*
259 * start timer
260 */
261 if(ppp_data->ona->restarts > 0)
262 ppp_data->ona->restarts--;
263 sig_any_rt_rrt_req();
264 break;
265 default:
266 TRACE_ERROR( "SIG_ANY_ONA_CLOSE_IND unexpected" );
267 arb_discard_packet(packet);
268 break;
269 }
270 } /* sig_any_ona_close_ind() */
271
272
273
274 /*
275 +------------------------------------------------------------------------------
276 | Function : sig_any_ona_rtr_ind
277 +------------------------------------------------------------------------------
278 | Description : Handles the internal signal SIG_ANY_ONA_RTR_IND
279 |
280 | Parameters : ptype - type of packet
281 | packet - pointer to a generic data descriptor
282 |
283 +------------------------------------------------------------------------------
284 */
285 GLOBAL void sig_any_ona_rtr_ind (USHORT ptype, T_desc2* packet)
286 {
287 UBYTE index;
288
289 TRACE_ISIG( "sig_any_ona_rtr_ind" );
290
291 TRACE_EVENT( "Peer requested Termination by PPP frame" );
292
293 /*
294 * determine ONA-instance
295 */
296 ona_get_inst_index(ptype, &index);
297 ppp_data->ona = & ppp_data->ona_base[index];
298
299 switch( GET_STATE( PPP_SERVICE_ONA ) )
300 {
301 case ONA_CLOSING:
302 /*
303 * send terminate acknowledge
304 */
305 sig_any_ftx_packet_req(ptype, packet); /* sta */
306 break;
307 case ONA_OPENED:
308 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
309 /*
310 * send This-Layer-Down signal
311 */
312 if (ptype EQ DTI_PID_LCP)
313 {
314 sig_ona_lcp_tld_req();
315 }
316 else if (ptype EQ DTI_PID_IPCP)
317 {
318 sig_ona_ncp_tld_req();
319 }
320 ppp_data->ona = & ppp_data->ona_base[index];
321 case ONA_REQ_SENT:
322 case ONA_ACK_RCVD:
323 case ONA_ACK_SENT:
324 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
325 /*
326 * set counter to zero
327 */
328 ppp_data->ona->restarts = 0;
329 /*
330 * send terminate acknowledge
331 */
332 sig_any_ftx_packet_req(ptype, packet); /* sta */
333 /*
334 * start timer
335 */
336 sig_any_rt_rrt_req();
337 break;
338 default:
339 TRACE_ERROR( "SIG_ANY_ONA_RTR_IND unexpected" );
340 arb_discard_packet(packet);
341 break;
342 }
343
344 /*
345 * set error code
346 */
347 if(ppp_data->ppp_cause EQ 0)
348 ppp_data->ppp_cause = PPP_TERM_OK_PEER;
349
350 } /* sig_any_ona_rtr_ind() */
351
352
353
354 /*
355 +------------------------------------------------------------------------------
356 | Function : sig_any_ona_to_ind
357 +------------------------------------------------------------------------------
358 | Description : Handles the internal signal SIG_ANY_ONA_TO_IND
359 |
360 | Parameters : ptype - type of packet
361 |
362 +------------------------------------------------------------------------------
363 */
364 GLOBAL void sig_any_ona_to_ind (USHORT ptype)
365 {
366 UBYTE index;
367 T_desc2* packet = NULL;
368 TRACE_ISIG( "sig_any_ona_to_ind" );
369
370 /*
371 * determine ONA-instance
372 */
373 ona_get_inst_index(ptype, &index);
374 ppp_data->ona = & ppp_data->ona_base[index];
375
376 switch( GET_STATE( PPP_SERVICE_ONA ) )
377 {
378 case ONA_CLOSING:
379 if (ppp_data->ona->restarts EQ 0)
380 {
381 /*
382 * negative timeout
383 */
384 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
385 /*
386 * set error code
387 */
388 if(ppp_data->ppp_cause EQ 0)
389 ppp_data->ppp_cause = PPP_TERM_NO_RESPONSE;
390 /*
391 * send This-Layer-Finished signal
392 */
393 if (ptype EQ DTI_PID_LCP)
394 {
395 sig_ona_lcp_tlf_req();
396 }
397 else if (ptype EQ DTI_PID_IPCP)
398 {
399 sig_ona_ncp_tlf_req();
400 }
401 }
402 else
403 {
404 /*
405 * positive timeout
406 */
407 /*
408 * request a new terminate request packet
409 */
410 if (ptype EQ DTI_PID_LCP)
411 {
412 sig_ona_lcp_str_req(&packet);
413 }
414 else if (ptype EQ DTI_PID_IPCP)
415 {
416 sig_ona_ncp_str_req(&packet);
417 }
418 /*
419 * set counter and send terminate request packet
420 */
421 ppp_data->ona->restarts--;
422 sig_any_ftx_packet_req(ptype, packet); /* str */
423 /*
424 * restart timer
425 */
426 sig_any_rt_rrt_req();
427 }
428 break;
429 case ONA_REQ_SENT:
430 case ONA_ACK_SENT:
431 if (ppp_data->ona->restarts EQ 0)
432 {
433 /*
434 * negative timeout
435 */
436 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
437 /*
438 * set error code
439 */
440 if(ppp_data->ppp_cause EQ 0)
441 ppp_data->ppp_cause = PPP_TERM_NO_RESPONSE;
442 /*
443 * send This-Layer-Finished signal
444 */
445 if (ptype EQ DTI_PID_LCP)
446 {
447 sig_ona_lcp_tlf_req();
448 }
449 else if (ptype EQ DTI_PID_IPCP)
450 {
451 sig_ona_ncp_tlf_req();
452 }
453 }
454 else
455 {
456 /*
457 * positive timeout
458 */
459 /*
460 * request a new configure request packet
461 */
462 if (ptype EQ DTI_PID_LCP)
463 {
464 sig_ona_lcp_scr_req(&packet);
465 }
466 else if (ptype EQ DTI_PID_IPCP)
467 {
468 sig_ona_ncp_scr_req(&packet);
469 }
470 /*
471 * set counter and send configure request packet
472 */
473 ppp_data->ona->restarts--;
474 sig_any_ftx_packet_req(ptype, packet); /* scr */
475 /*
476 * restart timer
477 */
478 sig_any_rt_rrt_req();
479 }
480 break;
481 case ONA_ACK_RCVD:
482 if (ppp_data->ona->restarts EQ 0)
483 {
484 /*
485 * negative timeout
486 */
487 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
488 /*
489 * set error code
490 */
491 if(ppp_data->ppp_cause EQ 0)
492 ppp_data->ppp_cause = PPP_TERM_NO_RESPONSE;
493 /*
494 * send This-Layer-Finished signal
495 */
496 if (ptype EQ DTI_PID_LCP)
497 {
498 sig_ona_lcp_tlf_req();
499 }
500 else if (ptype EQ DTI_PID_IPCP)
501 {
502 sig_ona_ncp_tlf_req();
503 }
504 }
505 else
506 {
507 /*
508 * positive timeout
509 */
510 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
511 /*
512 * request a new configure request packet
513 */
514 if (ptype EQ DTI_PID_LCP)
515 {
516 sig_ona_lcp_scr_req(&packet);
517 }
518 else if (ptype EQ DTI_PID_IPCP)
519 {
520 sig_ona_ncp_scr_req(&packet);
521 }
522 /*
523 * set counter and send configure request packet
524 */
525 ppp_data->ona->restarts--;
526 sig_any_ftx_packet_req(ptype, packet); /* scr */
527 /*
528 * restart timer
529 */
530 sig_any_rt_rrt_req();
531 }
532 break;
533 default:
534 TRACE_ERROR( "SIG_ANY_ONA_TO_IND unexpected" );
535 break;
536 }
537 } /* sig_any_ona_to_ind() */
538
539
540
541 /*
542 +------------------------------------------------------------------------------
543 | Function : sig_any_ona_rta_ind
544 +------------------------------------------------------------------------------
545 | Description : Handles the internal signal SIG_ANY_ONA_RTA_IND
546 |
547 | Parameters : ptype - type of packet
548 |
549 +------------------------------------------------------------------------------
550 */
551 GLOBAL void sig_any_ona_rta_ind (USHORT ptype)
552 {
553 UBYTE index;
554 T_desc2* packet = NULL;
555 TRACE_ISIG( "sig_any_ona_rta_ind" );
556
557 /*
558 * determine ONA-instance
559 */
560 ona_get_inst_index(ptype, &index);
561 ppp_data->ona = & ppp_data->ona_base[index];
562
563 switch( GET_STATE( PPP_SERVICE_ONA ) )
564 {
565 case ONA_CLOSING:
566 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
567 /*
568 * stop timer
569 */
570 sig_any_rt_srt_req();
571 /*
572 * send This-Layer-Finished signal
573 */
574 if (ptype EQ DTI_PID_LCP)
575 {
576 sig_ona_lcp_tlf_req();
577 }
578 else if (ptype EQ DTI_PID_IPCP)
579 {
580 sig_ona_ncp_tlf_req();
581 }
582 break;
583 case ONA_REQ_SENT:
584 case ONA_ACK_RCVD:
585 case ONA_ACK_SENT:
586 break;
587 case ONA_OPENED:
588 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
589 /*
590 * send This-Layer-Down signal and
591 * request a new configure request packet
592 */
593 if (ptype EQ DTI_PID_LCP)
594 {
595 sig_ona_lcp_tld_req();
596 sig_ona_lcp_scr_req(&packet);
597 }
598 else if (ptype EQ DTI_PID_IPCP)
599 {
600 sig_ona_ncp_tld_req();
601 sig_ona_ncp_scr_req(&packet);
602 }
603 ppp_data->ona = & ppp_data->ona_base[index];
604 /*
605 * send configure request packet
606 */
607 sig_any_ftx_packet_req(ptype, packet); /* scr */
608 /*
609 * start timer
610 */
611 if(ppp_data->ona->restarts > 0)
612 ppp_data->ona->restarts--;
613 sig_any_rt_rrt_req();
614 break;
615 default:
616 TRACE_ERROR( "SIG_ANY_ONA_RTA_IND unexpected" );
617 break;
618 }
619 } /* sig_any_ona_rta_ind() */
620
621
622
623 /*
624 +------------------------------------------------------------------------------
625 | Function : sig_any_ona_rxjn_ind
626 +------------------------------------------------------------------------------
627 | Description : Handles the internal signal SIG_ANY_ONA_RXJN_IND
628 |
629 | Parameters : ptype - type of packet
630 | packet - pointer to a generic data descriptor
631 |
632 +------------------------------------------------------------------------------
633 */
634 GLOBAL void sig_any_ona_rxjn_ind (USHORT ptype, T_desc2* packet)
635 {
636 UBYTE index;
637 TRACE_ISIG( "sig_any_ona_rxjn_ind" );
638
639 /*
640 * determine ONA-instance
641 */
642 ona_get_inst_index(ptype, &index);
643 ppp_data->ona = & ppp_data->ona_base[index];
644
645 /*
646 * set error code
647 */
648 if(ppp_data->ppp_cause EQ 0)
649 {
650 switch(ptype)
651 {
652 case DTI_PID_LCP:
653 ppp_data->ppp_cause = PPP_TERM_LCP_NOT_CONVERGE;
654 break;
655 case DTI_PID_IPCP:
656 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_CONVERGE;
657 break;
658 }
659 }
660
661 switch( GET_STATE( PPP_SERVICE_ONA ) )
662 {
663 case ONA_CLOSING:
664 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSED );
665 arb_discard_packet(packet);
666 /*
667 * stop timer
668 */
669 sig_any_rt_srt_req();
670 /*
671 * send This-Layer-Finished signal
672 */
673 if (ptype EQ DTI_PID_LCP)
674 {
675 sig_ona_lcp_tlf_req();
676 }
677 else if (ptype EQ DTI_PID_IPCP)
678 {
679 sig_ona_ncp_tlf_req();
680 }
681 break;
682 case ONA_OPENED:
683 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
684 /*
685 * send This-Layer-Down signal
686 */
687 if (ptype EQ DTI_PID_LCP)
688 {
689 sig_ona_lcp_tld_req();
690 }
691 else if (ptype EQ DTI_PID_IPCP)
692 {
693 sig_ona_ncp_tld_req();
694 }
695 ppp_data->ona = & ppp_data->ona_base[index];
696 case ONA_REQ_SENT:
697 case ONA_ACK_RCVD:
698 case ONA_ACK_SENT:
699 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
700 /*
701 * set counter
702 */
703 ppp_data->ona->restarts = ppp_data->mt;
704 /*
705 * send terminate request packet
706 */
707 sig_any_ftx_packet_req(ptype, packet); /* str */
708 /*
709 * start timer
710 */
711 if(ppp_data->ona->restarts > 0)
712 ppp_data->ona->restarts--;
713 sig_any_rt_rrt_req();
714 break;
715 default:
716 TRACE_ERROR( "SIG_ANY_ONA_RXJN_IND unexpected" );
717 arb_discard_packet(packet);
718 break;
719 }
720 } /* sig_any_ona_rxjn_ind() */
721
722
723
724 /*
725 +------------------------------------------------------------------------------
726 | Function : sig_any_ona_rcrn_ind
727 +------------------------------------------------------------------------------
728 | Description : Handles the internal signal SIG_ANY_ONA_RCRN_IND
729 |
730 | Parameters : ptype - type of packet
731 | packet - pointer to a generic data descriptor
732 | newFlag - flag
733 |
734 +------------------------------------------------------------------------------
735 */
736 GLOBAL void sig_any_ona_rcrn_ind (USHORT ptype, T_desc2* packet, UBYTE newFlag)
737 {
738 UBYTE index;
739 T_desc2* req_packet = NULL;
740
741 TRACE_ISIG( "sig_any_ona_rcrn_ind" );
742
743 /*
744 * determine ONA-instance
745 */
746 ona_get_inst_index(ptype, &index);
747 ppp_data->ona = & ppp_data->ona_base[index];
748
749 switch( GET_STATE( PPP_SERVICE_ONA ) )
750 {
751 case ONA_CLOSING:
752 arb_discard_packet(packet);
753 break;
754 case ONA_REQ_SENT:
755 case ONA_ACK_SENT:
756 if (ppp_data->ona->failures EQ 0)
757 {
758 /*
759 * protocol not converge
760 */
761 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
762 /*
763 * set error code
764 */
765 if(ppp_data->ppp_cause EQ 0)
766 {
767 switch(ptype)
768 {
769 case DTI_PID_LCP:
770 ppp_data->ppp_cause = PPP_TERM_LCP_NOT_CONVERGE;
771 break;
772 case DTI_PID_IPCP:
773 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_CONVERGE;
774 break;
775 }
776 }
777 arb_discard_packet(packet);
778 /*
779 * set counter
780 */
781 ppp_data->ona->restarts = ppp_data->mt;
782 /*
783 * request terminate request packet
784 */
785 if (ptype EQ DTI_PID_LCP)
786 {
787 sig_ona_lcp_str_req(&packet);
788 }
789 else if (ptype EQ DTI_PID_IPCP)
790 {
791 sig_ona_ncp_str_req(&packet);
792 }
793 /*
794 * send terminate request
795 */
796 sig_any_ftx_packet_req(ptype, packet); /* str */
797 /*
798 * start timer
799 */
800 if(ppp_data->ona->restarts > 0)
801 ppp_data->ona->restarts--;
802 sig_any_rt_rrt_req();
803 }
804 else
805 {
806 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
807 /*
808 * send configure nak packet
809 */
810 sig_any_ftx_packet_req(ptype, packet); /* scn */
811 if (newFlag EQ TRUE)
812 {
813 ppp_data->ona->failures--;
814 }
815 }
816 break;
817 case ONA_ACK_RCVD:
818 if (ppp_data->ona->failures EQ 0)
819 {
820 /*
821 * protocol not converge
822 */
823 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
824 /*
825 * set error code
826 */
827 if(ppp_data->ppp_cause EQ 0)
828 {
829 switch(ptype)
830 {
831 case DTI_PID_LCP:
832 ppp_data->ppp_cause = PPP_TERM_LCP_NOT_CONVERGE;
833 break;
834 case DTI_PID_IPCP:
835 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_CONVERGE;
836 break;
837 }
838 }
839 arb_discard_packet(packet);
840 /*
841 * set counter
842 */
843 ppp_data->ona->restarts = ppp_data->mt;
844 /*
845 * request terminate request packet
846 */
847 if (ptype EQ DTI_PID_LCP)
848 {
849 sig_ona_lcp_str_req(&packet);
850 }
851 else if (ptype EQ DTI_PID_IPCP)
852 {
853 sig_ona_ncp_str_req(&packet);
854 }
855 /*
856 * send terminate request packet
857 */
858 sig_any_ftx_packet_req(ptype, packet); /* str */
859 /*
860 * start timer
861 */
862 if(ppp_data->ona->restarts > 0)
863 ppp_data->ona->restarts--;
864 sig_any_rt_rrt_req();
865 }
866 else
867 {
868 /*
869 * send configure nak packet
870 */
871 sig_any_ftx_packet_req(ptype, packet); /* scn */
872 if (newFlag EQ TRUE)
873 {
874 ppp_data->ona->failures--;
875 sig_any_rt_rrt_req();
876 }
877 }
878 break;
879 case ONA_OPENED:
880 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
881 /*
882 * send This_Layer_Down signal and
883 * request configure request packet
884 */
885 if (ptype EQ DTI_PID_LCP)
886 {
887 sig_ona_lcp_tld_req();
888 sig_ona_lcp_scr_req(&req_packet);
889 }
890 else if (ptype EQ DTI_PID_IPCP)
891 {
892 sig_ona_ncp_tld_req();
893 sig_ona_ncp_scr_req(&req_packet);
894 }
895 ppp_data->ona = & ppp_data->ona_base[index];
896 /*
897 * send configure request packet
898 */
899 sig_any_ftx_packet_req(ptype, req_packet); /* scr */
900 if(ppp_data->ona->restarts > 0)
901 ppp_data->ona->restarts--;
902 if ((newFlag EQ TRUE) && (ppp_data->ona->failures > 0))
903 {
904 ppp_data->ona->failures--;
905 }
906 /*
907 * send configure nak packet
908 */
909 sig_any_ftx_packet_req(ptype, packet); /* scn */
910 /*
911 * start timer
912 */
913 sig_any_rt_rrt_req();
914 break;
915 default:
916 TRACE_ERROR( "SIG_ANY_ONA_RCRN_IND unexpected" );
917 break;
918 }
919 } /* sig_any_ona_rcrn_ind() */
920
921
922
923 /*
924 +------------------------------------------------------------------------------
925 | Function : sig_any_ona_rcrp_ind
926 +------------------------------------------------------------------------------
927 | Description : Handles the internal signal SIG_ANY_ONA_RCRP_IND
928 |
929 | Parameters : ptype - type of packet
930 | packet - pointer to a generic data descriptor
931 |
932 +------------------------------------------------------------------------------
933 */
934 GLOBAL void sig_any_ona_rcrp_ind (USHORT ptype, T_desc2* packet)
935 {
936 UBYTE index;
937 T_desc2* req_packet = NULL;
938 TRACE_ISIG( "sig_any_ona_rcrp_ind" );
939
940 /*
941 * determine ONA-instance
942 */
943 ona_get_inst_index(ptype, &index);
944 ppp_data->ona = & ppp_data->ona_base[index];
945
946 switch( GET_STATE( PPP_SERVICE_ONA ) )
947 {
948 case ONA_CLOSING:
949 arb_discard_packet(packet);
950 break;
951 case ONA_REQ_SENT:
952 case ONA_ACK_SENT:
953 SET_STATE( PPP_SERVICE_ONA, ONA_ACK_SENT );
954 /*
955 * set counter
956 */
957 ppp_data->ona->failures = ppp_data->mf;
958 /*
959 * send configure acknowledge packet
960 */
961 sig_any_ftx_packet_req(ptype, packet); /* sca */
962 break;
963 case ONA_ACK_RCVD:
964 SET_STATE( PPP_SERVICE_ONA, ONA_OPENED );
965 /*
966 * stop timer
967 */
968 sig_any_rt_srt_req();
969 /*
970 * reset counter
971 */
972 ppp_data->ona->failures = ppp_data->mf;
973 /*
974 * send configure acknowledge packet
975 */
976 sig_any_ftx_packet_req(ptype, packet); /* sca */
977 /*
978 * send This-Layer_Up signal
979 */
980 if (ptype EQ DTI_PID_LCP)
981 {
982 sig_ona_lcp_tlu_req();
983 }
984 else if (ptype EQ DTI_PID_IPCP)
985 {
986 sig_ona_ncp_tlu_req();
987 }
988 break;
989 case ONA_OPENED:
990 SET_STATE( PPP_SERVICE_ONA, ONA_ACK_SENT );
991 /*
992 * send This-Layer-Down signal and
993 * request configure request packet
994 */
995 if (ptype EQ DTI_PID_LCP)
996 {
997 sig_ona_lcp_tld_req();
998 sig_ona_lcp_scr_req(&req_packet);
999 }
1000 else if (ptype EQ DTI_PID_IPCP)
1001 {
1002 sig_ona_ncp_tld_req();
1003 sig_ona_ncp_scr_req(&req_packet);
1004 }
1005 ppp_data->ona = & ppp_data->ona_base[index];
1006 /*
1007 * send configure request packet
1008 */
1009 sig_any_ftx_packet_req(ptype, req_packet); /* scr */
1010 if(ppp_data->ona->restarts > 0)
1011 ppp_data->ona->restarts--;
1012 /*
1013 * send configure acknowledge packet
1014 */
1015 sig_any_ftx_packet_req(ptype, packet); /* sca */
1016 /*
1017 * restart timer
1018 */
1019 sig_any_rt_rrt_req();
1020 break;
1021 default:
1022 TRACE_ERROR( "SIG_ANY_ONA_RCRP_IND unexpected" );
1023 arb_discard_packet(packet);
1024 break;
1025 }
1026 } /* sig_any_ona_rcrp_ind() */
1027
1028
1029
1030 /*
1031 +------------------------------------------------------------------------------
1032 | Function : sig_any_ona_rcn_ind
1033 +------------------------------------------------------------------------------
1034 | Description : Handles the internal signal SIG_ANY_ONA_RCN_IND
1035 |
1036 | Parameters : ptype - type of packet
1037 | packet - pointer to a generic data descriptor
1038 |
1039 +------------------------------------------------------------------------------
1040 */
1041 GLOBAL void sig_any_ona_rcn_ind (USHORT ptype, T_desc2* packet)
1042 {
1043 UBYTE index;
1044 TRACE_ISIG( "sig_any_ona_rcn_ind" );
1045
1046 /*
1047 * determine ONA-instance
1048 */
1049 ona_get_inst_index(ptype, &index);
1050 ppp_data->ona = & ppp_data->ona_base[index];
1051
1052 switch( GET_STATE( PPP_SERVICE_ONA ) )
1053 {
1054 case ONA_CLOSING:
1055 arb_discard_packet(packet);
1056 break;
1057 case ONA_REQ_SENT:
1058 case ONA_ACK_SENT:
1059 /*
1060 * reset counter
1061 */
1062 ppp_data->ona->restarts = ppp_data->mc;
1063 /*
1064 * send configure request packet
1065 */
1066 sig_any_ftx_packet_req(ptype, packet); /* scr */
1067 /*
1068 * start timer
1069 */
1070 if(ppp_data->ona->restarts > 0)
1071 ppp_data->ona->restarts--;
1072 sig_any_rt_rrt_req();
1073 break;
1074 case ONA_ACK_RCVD:
1075 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
1076 /*
1077 * send configure request packet
1078 */
1079 sig_any_ftx_packet_req(ptype, packet); /* scr */
1080 /*
1081 * start timer
1082 */
1083 sig_any_rt_rrt_req();
1084 break;
1085 case ONA_OPENED:
1086 SET_STATE( PPP_SERVICE_ONA, ONA_REQ_SENT );
1087 /*
1088 * send This-Layer-Down signal
1089 */
1090 if (ptype EQ DTI_PID_LCP)
1091 {
1092 sig_ona_lcp_tld_req();
1093 }
1094 else if (ptype EQ DTI_PID_IPCP)
1095 {
1096 sig_ona_ncp_tld_req();
1097 }
1098 ppp_data->ona = & ppp_data->ona_base[index];
1099 /*
1100 * send configure request packet
1101 */
1102 sig_any_ftx_packet_req(ptype, packet); /* scr */
1103 /*
1104 * start timer
1105 */
1106 if(ppp_data->ona->restarts > 0)
1107 ppp_data->ona->restarts--;
1108 sig_any_rt_rrt_req();
1109 break;
1110 default:
1111 TRACE_ERROR( "SIG_ANY_ONA_RCN_IND unexpected" );
1112 arb_discard_packet(packet);
1113 break;
1114 }
1115 } /* sig_any_ona_rcn_ind() */
1116
1117
1118
1119 /*
1120 +------------------------------------------------------------------------------
1121 | Function : sig_any_ona_rca_ind
1122 +------------------------------------------------------------------------------
1123 | Description : Handles the internal signal SIG_ANY_ONA_RCA_IND
1124 |
1125 | Parameters : ptype - type of packet
1126 |
1127 +------------------------------------------------------------------------------
1128 */
1129 GLOBAL void sig_any_ona_rca_ind (USHORT ptype)
1130 {
1131 UBYTE index;
1132 T_desc2* temp_desc = NULL;
1133
1134 TRACE_ISIG( "sig_any_ona_rca_ind" );
1135
1136 /*
1137 * determine ONA-instance
1138 */
1139 ona_get_inst_index(ptype, &index);
1140 ppp_data->ona = & ppp_data->ona_base[index];
1141
1142 switch( GET_STATE( PPP_SERVICE_ONA ) )
1143 {
1144 case ONA_CLOSING:
1145 case ONA_ACK_RCVD:
1146 case ONA_OPENED:
1147 break;
1148 case ONA_REQ_SENT:
1149 if(ppp_data->ona->loops EQ 0)
1150 {
1151 /*
1152 * protocol not converge
1153 */
1154 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
1155 /*
1156 * set error code
1157 */
1158 if(ppp_data->ppp_cause EQ 0)
1159 {
1160 switch(ptype)
1161 {
1162 case DTI_PID_LCP:
1163 ppp_data->ppp_cause = PPP_TERM_LCP_NOT_CONVERGE;
1164 break;
1165 case DTI_PID_IPCP:
1166 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_CONVERGE;
1167 break;
1168 }
1169 }
1170 /*
1171 * set counter
1172 */
1173 ppp_data->ona->restarts = ppp_data->mt;
1174 /*
1175 * request terminate request packet
1176 */
1177 if (ptype EQ DTI_PID_LCP)
1178 {
1179 sig_ona_lcp_str_req(&temp_desc);
1180 }
1181 else if (ptype EQ DTI_PID_IPCP)
1182 {
1183 sig_ona_ncp_str_req(&temp_desc);
1184 }
1185 /*
1186 * send terminate request
1187 */
1188 sig_any_ftx_packet_req(ptype, temp_desc); /* str */
1189 /*
1190 * start timer
1191 */
1192 if(ppp_data->ona->restarts > 0)
1193 ppp_data->ona->restarts--;
1194 sig_any_rt_rrt_req();
1195 }
1196 else
1197 {
1198 SET_STATE( PPP_SERVICE_ONA, ONA_ACK_RCVD );
1199 /*
1200 * reset counters
1201 */
1202 ppp_data->ona->restarts = ppp_data->mc;
1203 ppp_data->ona->loops--;
1204 /*
1205 * start timer
1206 */
1207 sig_any_rt_rrt_req();
1208 }
1209 break;
1210
1211 case ONA_ACK_SENT:
1212 if(ppp_data->ona->loops EQ 0)
1213 {
1214 /*
1215 * protocol not converge
1216 */
1217 SET_STATE( PPP_SERVICE_ONA, ONA_CLOSING );
1218 /*
1219 * set error code
1220 */
1221 if(ppp_data->ppp_cause EQ 0)
1222 {
1223 switch(ptype)
1224 {
1225 case DTI_PID_LCP:
1226 ppp_data->ppp_cause = PPP_TERM_LCP_NOT_CONVERGE;
1227 break;
1228 case DTI_PID_IPCP:
1229 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_CONVERGE;
1230 break;
1231 }
1232 }
1233 /*
1234 * set counter
1235 */
1236 ppp_data->ona->restarts = ppp_data->mt;
1237 /*
1238 * request terminate request packet
1239 */
1240 if (ptype EQ DTI_PID_LCP)
1241 {
1242 sig_ona_lcp_str_req(&temp_desc);
1243 }
1244 else if (ptype EQ DTI_PID_IPCP)
1245 {
1246 sig_ona_ncp_str_req(&temp_desc);
1247 }
1248 /*
1249 * send terminate request
1250 */
1251 sig_any_ftx_packet_req(ptype, temp_desc); /* str */
1252 /*
1253 * start timer
1254 */
1255 if(ppp_data->ona->restarts > 0)
1256 ppp_data->ona->restarts--;
1257 sig_any_rt_rrt_req();
1258 }
1259 else
1260 {
1261 SET_STATE( PPP_SERVICE_ONA, ONA_OPENED );
1262 /*
1263 * stop timer
1264 */
1265 sig_any_rt_srt_req();
1266 /*
1267 * reset counter
1268 */
1269 ppp_data->ona->restarts = ppp_data->mc;
1270 ppp_data->ona->loops--;
1271 /*
1272 * send This_Layer_Up signal
1273 */
1274 if (ptype EQ DTI_PID_LCP)
1275 {
1276 sig_ona_lcp_tlu_req();
1277 }
1278 else if (ptype EQ DTI_PID_IPCP)
1279 {
1280 sig_ona_ncp_tlu_req();
1281 }
1282 }
1283 break;
1284
1285 default:
1286 TRACE_ERROR( "SIG_ANY_ONA_RCA_IND unexpected" );
1287 break;
1288 }
1289 } /* sig_any_ona_rca_ind() */
1290
1291
1292
1293 /*
1294 +------------------------------------------------------------------------------
1295 | Function : sig_any_ona_rxr_ind
1296 +------------------------------------------------------------------------------
1297 | Description : Handles the internal signal SIG_ANY_ONA_RXR_IND
1298 |
1299 | Parameters : ptype - type of packet
1300 | packet - pointer to a generic data descriptor
1301 |
1302 +------------------------------------------------------------------------------
1303 */
1304 GLOBAL void sig_any_ona_rxr_ind (USHORT ptype, T_desc2* packet)
1305 {
1306 UBYTE index;
1307 TRACE_ISIG( "sig_any_ona_rxr_ind" );
1308
1309 /*
1310 * determine ONA-instance
1311 */
1312 ona_get_inst_index(ptype, &index);
1313 ppp_data->ona = & ppp_data->ona_base[index];
1314
1315 switch( GET_STATE( PPP_SERVICE_ONA ) )
1316 {
1317 case ONA_CLOSING:
1318 case ONA_REQ_SENT:
1319 case ONA_ACK_RCVD:
1320 case ONA_ACK_SENT:
1321 arb_discard_packet(packet);
1322 break;
1323 case ONA_OPENED:
1324 /*
1325 * send echo reply packet
1326 */
1327 sig_any_ftx_packet_req(ptype, packet); /* ser */
1328 break;
1329 default:
1330 TRACE_ERROR( "SIG_ANY_ONA_RXR_IND unexpected" );
1331 arb_discard_packet(packet);
1332 break;
1333 }
1334 } /* sig_any_ona_rxr_ind() */