comparison src/g23m-fad/ppp/ppp_onaf.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 | procedures and functions as described in the
19 | SDL-documentation (ONA-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef PPP_ONAF_C
24 #define PPP_ONAF_C
25 #endif /* !PPP_ONAF_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 /*==== CONST ================================================================*/
43
44 /*==== LOCAL VARS ===========================================================*/
45
46 /*==== PRIVATE FUNCTIONS ====================================================*/
47
48 /*==== PUBLIC FUNCTIONS =====================================================*/
49
50
51
52 /*
53 +------------------------------------------------------------------------------
54 | Function : ona_init
55 +------------------------------------------------------------------------------
56 | Description : The function ona_init() initializes the option negotiation
57 | automaton (ONA)
58 |
59 | Parameters : no parameters
60 |
61 +------------------------------------------------------------------------------
62 */
63 GLOBAL void ona_init ()
64 {
65 UBYTE i;
66
67 TRACE_FUNCTION( "ona_init" );
68
69 for (i = 0;i < ONA_NUM_INC;i++)
70 {
71 ppp_data->ona = & ppp_data->ona_base[i];
72
73 /* counter for Configure-Request and Terminate-Request sent */
74 ppp_data->ona->restarts = 0;
75 /* counter for Configure-Nak and Configure-Reject sent */
76 ppp_data->ona->failures = 0;
77 /*
78 * counter for Configure-Ack received
79 * this counter avoids endless loops where the PPP peer always answers with
80 * a Configure-Ack, but it does not send a Configure-Req
81 */
82 ppp_data->ona->loops = 0;
83
84 INIT_STATE( PPP_SERVICE_ONA , ONA_CLOSED );
85 }
86 } /* ona_init() */
87
88
89 /*
90 +------------------------------------------------------------------------------
91 | Function : ona_get_inst_index
92 +------------------------------------------------------------------------------
93 | Description : gets the index (0, 1) for the given ptype (DTI_PID_LCP,
94 | DTI_PID_IPCP). This function is used when a calling service serves a key for
95 | one of the 2 possible instances of services LCR and NCR.
96 |
97 | Parameters : USHORT ptype, UBYTE* index
98 |
99 +------------------------------------------------------------------------------
100 */
101 GLOBAL void ona_get_inst_index(USHORT ptype,
102 UBYTE* index)
103 {
104 TRACE_FUNCTION("ona_get_inst_index");
105
106 if (ptype EQ DTI_PID_LCP)
107 {
108 *index = 0;
109 }
110 else if (ptype EQ DTI_PID_IPCP)
111 {
112 *index = 1;
113 }
114 else
115 {
116 TRACE_ERROR( "ONA_GET_INST_INDEX unexpected ptype" );
117 *index = 0;
118 }
119 }
120