comparison src/g23m-fad/ppp/ppp_paps.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 (PAP-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef PPP_PAPS_C
24 #define PPP_PAPS_C
25 #endif /* !PPP_PAPS_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_papf.h" /* to get function interface from pap */
43 #include "ppp_arbf.h" /* to get function interface from arb */
44 #include "ppp_ftxs.h" /* to get signal interface from ftx */
45 #include "ppp_arbs.h" /* to get signal interface from arb */
46 #include "ppp_rts.h" /* to get the rt signal interface */
47
48 /*==== CONST ================================================================*/
49
50 /*==== LOCAL VARS ===========================================================*/
51
52 /*==== PRIVATE FUNCTIONS ====================================================*/
53
54 /*==== PUBLIC FUNCTIONS =====================================================*/
55
56 /*
57 +------------------------------------------------------------------------------
58 | Function : sig_arb_pap_packet_req
59 +------------------------------------------------------------------------------
60 | Description : Handles the internal signal SIG_ARB_PAP_PACKET_REQ
61 |
62 | Parameters : packet - pointer to a generic data descriptor
63 |
64 +------------------------------------------------------------------------------
65 */
66 GLOBAL void sig_arb_pap_packet_req (T_desc2* packet)
67 {
68 UBYTE forward;
69
70 TRACE_ISIG( "sig_arb_pap_packet_req" );
71
72 /*
73 * depend on the code-field call appropriate function
74 */
75 switch(packet->buffer[0])
76 {
77 case CODE_AUTH_REQ:
78 pap_rar(&packet, &forward);
79 break;
80 case CODE_AUTH_ACK:
81 pap_raa(packet, &forward);
82 break;
83 case CODE_AUTH_NAK:
84 pap_ran(packet, &forward);
85 break;
86 default:
87 forward = FORWARD_DISCARD;
88 break;
89 }
90 switch(forward)
91 {
92 case FORWARD_RARP:
93 /*
94 * send Authentication Ack packets until receive a stop signal from arb
95 * or the counter becomes zero
96 */
97 SET_STATE( PPP_SERVICE_PAP, PAP_UP );
98 ppp_data->pap.counter = ppp_data->mc;
99 sig_any_ftx_packet_req(DTI_PID_PAP, packet); /* saa */
100 if(ppp_data->pap.counter > 0)
101 ppp_data->pap.counter--;
102 sig_any_rt_rrt_req();
103 sig_any_arb_tlu_ind();
104 break;
105 case FORWARD_RARN:
106 /*
107 * just send Authentication NAK packet and
108 * wait for next Authentication Request
109 * to avoid endless authentication timer will not restarted
110 */
111 sig_any_ftx_packet_req(DTI_PID_PAP, packet); /* san */
112 break;
113 case FORWARD_RAA:
114 /*
115 * Authentication successful
116 */
117 sig_any_rt_srt_req();
118 sig_any_arb_tlu_ind();
119 break;
120 case FORWARD_RAN:
121 /*
122 * send new Authentication Request
123 */
124 ppp_data->pap.counter = ppp_data->mc;
125 /*
126 * set new identifier
127 */
128 ppp_data->pap.nari++;
129 /*
130 * create and send authenticate request packet
131 */
132 pap_get_sar(&packet);
133 sig_any_ftx_packet_req(DTI_PID_PAP, packet);
134 if(ppp_data->pap.counter > 0)
135 ppp_data->pap.counter--;
136 sig_any_rt_rrt_req();
137 break;
138 default:
139 arb_discard_packet(packet);
140 break;
141 }
142 } /* sig_arb_pap_packet_req() */
143
144
145
146 /*
147 +------------------------------------------------------------------------------
148 | Function : sig_arb_pap_open_req
149 +------------------------------------------------------------------------------
150 | Description : Handles the internal signal SIG_ARB_PAP_OPEN_REQ
151 |
152 | Parameters : no parameters
153 |
154 +------------------------------------------------------------------------------
155 */
156 GLOBAL void sig_arb_pap_open_req ()
157 {
158 T_desc2* packet;
159
160 TRACE_ISIG( "sig_arb_pap_open_req" );
161
162 SET_STATE( PPP_SERVICE_PAP, PAP_DOWN );
163 ppp_data->pap.counter = ppp_data->mc;
164
165 if(ppp_data->mode EQ PPP_CLIENT)
166 {
167 /*
168 * set new identifier
169 */
170 ppp_data->pap.nari++;
171 /*
172 * create and send authenticate request packet
173 */
174 pap_get_sar(&packet);
175 sig_any_ftx_packet_req(DTI_PID_PAP, packet);
176 }
177
178 if(ppp_data->pap.counter > 0)
179 ppp_data->pap.counter--;
180 sig_any_rt_rrt_req();
181 } /* sig_arb_pap_open_req() */
182
183
184
185 /*
186 +------------------------------------------------------------------------------
187 | Function : sig_arb_pap_down_req
188 +------------------------------------------------------------------------------
189 | Description : Handles the internal signal SIG_ARB_PAP_DOWN_REQ
190 |
191 | Parameters : no parameters
192 |
193 +------------------------------------------------------------------------------
194 */
195 GLOBAL void sig_arb_pap_down_req ()
196 {
197 TRACE_ISIG( "sig_arb_pap_down_req" );
198
199 sig_any_rt_srt_req();
200 arb_discard_packet(ppp_data->pap.ar_packet);
201 ppp_data->pap.ar_packet = NULL;
202 } /* sig_arb_pap_down_req() */
203
204
205
206 /*
207 +------------------------------------------------------------------------------
208 | Function : sig_arb_pap_stop_req
209 +------------------------------------------------------------------------------
210 | Description : Handles the internal signal SIG_ARB_PAP_STOP_REQ
211 |
212 | Parameters : no parameters
213 |
214 +------------------------------------------------------------------------------
215 */
216 GLOBAL void sig_arb_pap_stop_req ()
217 {
218 TRACE_ISIG( "sig_arb_pap_stop_req" );
219
220 sig_any_rt_srt_req();
221 } /* sig_arb_pap_stop_req() */
222
223
224
225 /*
226 +------------------------------------------------------------------------------
227 | Function : sig_arb_pap_to_req
228 +------------------------------------------------------------------------------
229 | Description : Handles the internal signal SIG_ARB_PAP_TO_REQ
230 |
231 | Parameters : no parameters
232 |
233 +------------------------------------------------------------------------------
234 */
235 GLOBAL void sig_arb_pap_to_req ()
236 {
237 T_desc2* packet;
238
239 TRACE_ISIG( "sig_arb_pap_to_req" );
240
241 if (ppp_data->pap.counter EQ 0)
242 {
243 /*
244 * authentication failed (client and server mode)
245 */
246 if((ppp_data->ppp_cause EQ 0) && (ppp_data->mode EQ PPP_CLIENT))
247 ppp_data->ppp_cause = PPP_TERM_NO_RESPONSE;
248 sig_any_arb_tlf_ind();
249 }
250 else
251 {
252 if(ppp_data->mode EQ PPP_CLIENT)
253 {
254 /*
255 * send new authentication request packet
256 */
257 pap_get_sar(&packet);
258 sig_any_ftx_packet_req(DTI_PID_PAP, packet);
259 }
260 else /* server mode */
261 {
262 switch( GET_STATE( PPP_SERVICE_PAP ) )
263 {
264 case PAP_UP:
265 /*
266 * send new authentication ack packet
267 */
268 pap_get_saa(&packet);
269 sig_any_ftx_packet_req(DTI_PID_PAP, packet);
270 break;
271 }
272 }
273 /*
274 * restart timer
275 */
276 ppp_data->pap.counter--;
277 sig_any_rt_rrt_req();
278 }
279 } /* sig_arb_pap_to_req() */