FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/ppp/ppp_arbs.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 (ARB-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef PPP_ARBS_C | |
24 #define PPP_ARBS_C | |
25 #endif /* !PPP_ARBS_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 function interface from arb */ | |
43 #include "ppp_lcpf.h" /* to get function interface from lcp */ | |
44 #include "ppp_ncpf.h" /* to get function interface from ncp */ | |
45 #include "ppp_rts.h" /* to get signal interface from rt */ | |
46 #include "ppp_ptxs.h" /* to get signal interface from ptx */ | |
47 #include "ppp_ftxs.h" /* to get signal interface from ftx */ | |
48 #include "ppp_lcps.h" /* to get signal interface from lcp */ | |
49 #include "ppp_ncps.h" /* to get signal interface from ncp */ | |
50 #include "ppp_paps.h" /* to get signal interface from pap */ | |
51 #include "ppp_caps.h" /* to get signal interface from chap */ | |
52 #include "ppp_ftxs.h" /* to get signal interface from ftx */ | |
53 #include "ppp_prxs.h" /* to get signal interface from prx */ | |
54 #include "ppp_frxs.h" /* to get signal interface from frx */ | |
55 | |
56 #ifdef _SIMULATION_ | |
57 #include <string.h> /* to get strcpy */ | |
58 #endif /* _SIMULATION_ */ | |
59 /*==== CONST ================================================================*/ | |
60 | |
61 /*==== LOCAL VARS ===========================================================*/ | |
62 | |
63 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
64 | |
65 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
66 | |
67 | |
68 | |
69 /* | |
70 +------------------------------------------------------------------------------ | |
71 | Function : sig_ptx_arb_packet_ind | |
72 +------------------------------------------------------------------------------ | |
73 | Description : Handles the internal signal SIG_PTX_ARB_PACKET_IND | |
74 | | |
75 | Parameters : ptype - type of packet | |
76 | packet - pointer to a generic data descriptor | |
77 | | |
78 +------------------------------------------------------------------------------ | |
79 */ | |
80 GLOBAL void sig_ptx_arb_packet_ind (USHORT ptype, T_desc2* packet) | |
81 { | |
82 TRACE_ISIG( "sig_ptx_arb_packet_ind" ); | |
83 | |
84 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
85 { | |
86 case ARB_LCP_ESTABLISH: | |
87 case ARB_LCP_PDP: | |
88 case ARB_LCP_NCP: | |
89 case ARB_LCP_RECONF: | |
90 case ARB_LCP_MOD: | |
91 /* | |
92 * any non-LCP packets received during this phase must be | |
93 * silently discarded | |
94 */ | |
95 switch(ptype) | |
96 { | |
97 case DTI_PID_LCP: | |
98 sig_arb_lcp_packet_req(packet); | |
99 break; | |
100 default: | |
101 arb_discard_packet(packet); | |
102 break; | |
103 } | |
104 break; | |
105 case ARB_PAP_ESTABLISH: | |
106 /* | |
107 * only LCP and Authentication packets | |
108 * are allowed during this phase | |
109 * all other packets are silently discarded | |
110 * if we are in client mode and an IPCP Configure Req packet is received, | |
111 * we stop authentication and and start ncp | |
112 */ | |
113 switch(ptype) | |
114 { | |
115 case DTI_PID_LCP: | |
116 sig_arb_lcp_packet_req(packet); | |
117 break; | |
118 case DTI_PID_PAP: | |
119 sig_arb_pap_packet_req(packet); | |
120 break; | |
121 case DTI_PID_IPCP: | |
122 if (ppp_data->mode EQ PPP_CLIENT) | |
123 { | |
124 UBYTE result; | |
125 UBYTE hc; | |
126 UBYTE msid; | |
127 | |
128 ncp_analyze_first_ipcp(packet, &result, &hc, &msid); | |
129 if(result EQ TRUE) | |
130 { | |
131 /* | |
132 * start IPCP | |
133 */ | |
134 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_ESTABLISH ); | |
135 sig_arb_pap_stop_req(); | |
136 sig_arb_ncp_open_req(); | |
137 sig_arb_ncp_packet_req(packet); | |
138 break; | |
139 } | |
140 } | |
141 /* fall through */ | |
142 default: | |
143 arb_discard_packet(packet); | |
144 break; | |
145 } | |
146 break; | |
147 case ARB_PAP_RECONF: | |
148 /* | |
149 * only LCP and Authentication packets | |
150 * are allowed during this phase | |
151 * all other packets are silently discarded | |
152 * if we are in client mode and an IPCP Configure Req packet is received, | |
153 * we stop authentication and and start ncp | |
154 */ | |
155 switch(ptype) | |
156 { | |
157 case DTI_PID_LCP: | |
158 sig_arb_lcp_packet_req(packet); | |
159 break; | |
160 case DTI_PID_PAP: | |
161 sig_arb_pap_packet_req(packet); | |
162 break; | |
163 case DTI_PID_IPCP: | |
164 if (ppp_data->mode EQ PPP_CLIENT) | |
165 { | |
166 UBYTE result; | |
167 UBYTE hc; | |
168 UBYTE msid; | |
169 | |
170 ncp_analyze_first_ipcp(packet, &result, &hc, &msid); | |
171 if(result EQ TRUE) | |
172 { | |
173 /* | |
174 * start IPCP | |
175 */ | |
176 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
177 sig_arb_pap_stop_req(); | |
178 sig_arb_ncp_open_req(); | |
179 sig_arb_ncp_packet_req(packet); | |
180 break; | |
181 } | |
182 } | |
183 /* fall through */ | |
184 default: | |
185 arb_discard_packet(packet); | |
186 break; | |
187 } | |
188 break; | |
189 case ARB_CHAP_ESTABLISH: | |
190 /* | |
191 * only LCP and Authentication packets | |
192 * are allowed during this phase | |
193 * all other packets are silently discarded | |
194 * if we are in client mode and an IPCP Configure Req packet is received, | |
195 * we stop authentication and and start ncp | |
196 */ | |
197 switch(ptype) | |
198 { | |
199 case DTI_PID_LCP: | |
200 sig_arb_lcp_packet_req(packet); | |
201 break; | |
202 case DTI_PID_CHAP: | |
203 sig_arb_chap_packet_req(packet); | |
204 break; | |
205 case DTI_PID_IPCP: | |
206 if (ppp_data->mode EQ PPP_CLIENT) | |
207 { | |
208 UBYTE result; | |
209 UBYTE hc; | |
210 UBYTE msid; | |
211 | |
212 ncp_analyze_first_ipcp(packet, &result, &hc, &msid); | |
213 if(result EQ TRUE) | |
214 { | |
215 /* | |
216 * start IPCP | |
217 */ | |
218 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_ESTABLISH ); | |
219 sig_arb_chap_stop_req(); | |
220 sig_arb_ncp_open_req(); | |
221 sig_arb_ncp_packet_req(packet); | |
222 break; | |
223 } | |
224 } | |
225 /* fall through */ | |
226 default: | |
227 arb_discard_packet(packet); | |
228 break; | |
229 } | |
230 break; | |
231 case ARB_CHAP_RECONF: | |
232 /* | |
233 * only LCP and Authentication packets | |
234 * are allowed during this phase | |
235 * all other packets are silently discarded | |
236 * if we are in client mode and an IPCP Configure Req packet is received, | |
237 * we stop authentication and and start ncp | |
238 */ | |
239 switch(ptype) | |
240 { | |
241 case DTI_PID_LCP: | |
242 sig_arb_lcp_packet_req(packet); | |
243 break; | |
244 case DTI_PID_CHAP: | |
245 sig_arb_chap_packet_req(packet); | |
246 break; | |
247 case DTI_PID_IPCP: | |
248 if (ppp_data->mode EQ PPP_CLIENT) | |
249 { | |
250 UBYTE result; | |
251 UBYTE hc; | |
252 UBYTE msid; | |
253 | |
254 ncp_analyze_first_ipcp(packet, &result, &hc, &msid); | |
255 if(result EQ TRUE) | |
256 { | |
257 /* | |
258 * start IPCP | |
259 */ | |
260 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
261 sig_arb_chap_stop_req(); | |
262 sig_arb_ncp_open_req(); | |
263 sig_arb_ncp_packet_req(packet); | |
264 break; | |
265 } | |
266 } | |
267 /* fall through */ | |
268 default: | |
269 arb_discard_packet(packet); | |
270 break; | |
271 } | |
272 break; | |
273 case ARB_PDP_WAIT: | |
274 /* | |
275 * any protocol which is unsupported by the implementation must be | |
276 * returned in a Protocol-Reject packet | |
277 * LCP and IPCP are allowed | |
278 * other supported protocols are silently discarded | |
279 * arbitration waits for an IPCP Configure-Request packet from | |
280 * the PPP peer to create the list of Protocol Configuration Options | |
281 * and fill in the PPP_PDP_ACTIVATE_IND primitive | |
282 */ | |
283 switch(ptype) | |
284 { | |
285 case DTI_PID_LCP: | |
286 sig_arb_lcp_packet_req(packet); | |
287 break; | |
288 case DTI_PID_IPCP: | |
289 { | |
290 UBYTE result; | |
291 UBYTE hc; | |
292 UBYTE msid; | |
293 | |
294 ncp_analyze_first_ipcp(packet, &result, &hc, &msid); | |
295 if(result EQ TRUE) | |
296 { | |
297 PALLOC_SDU(ppp_pdp_activate_ind, PPP_PDP_ACTIVATE_IND, (251UL << 3)); | |
298 SET_STATE( PPP_SERVICE_ARB, ARB_PDP_SENT ); | |
299 sig_any_rt_srt_req(); | |
300 TRACE_EVENT("activating PDP context"); | |
301 if(hc EQ PPP_HC_OFF) | |
302 { | |
303 TRACE_EVENT("client does not support header compression"); | |
304 } | |
305 else if(hc EQ PPP_HC_VJ) | |
306 { | |
307 TRACE_EVENT("client supports VJ header compression"); | |
308 } | |
309 ppp_pdp_activate_ind->ppp_hc=hc; | |
310 ppp_pdp_activate_ind->msid=msid; | |
311 arb_get_pco_list (&ppp_pdp_activate_ind->sdu); | |
312 PSEND (hCommMMI, ppp_pdp_activate_ind); | |
313 } | |
314 /* | |
315 * store the packet | |
316 */ | |
317 if(ppp_data->arb.last_ipcp) | |
318 { | |
319 MFREE_DESC2(ppp_data->arb.last_ipcp); | |
320 } | |
321 ppp_data->arb.last_ipcp = packet; | |
322 } | |
323 break; | |
324 case DTI_PID_IP: | |
325 case DTI_PID_CTCP: | |
326 case DTI_PID_UTCP: | |
327 case DTI_PID_PAP: | |
328 case DTI_PID_CHAP: | |
329 arb_discard_packet(packet); | |
330 break; | |
331 default: | |
332 { | |
333 T_desc2* temp_desc; | |
334 | |
335 arb_get_protocol_reject (ptype, packet, &temp_desc); | |
336 sig_any_ftx_packet_req(DTI_PID_LCP, temp_desc); | |
337 } | |
338 break; | |
339 } | |
340 break; | |
341 case ARB_PDP_SENT: | |
342 /* | |
343 * any protocol which is unsupported by the implementation must be | |
344 * returned in a Protocol-Reject packet | |
345 * only LCP and IPCP are allowed | |
346 * IPCP packets are stored until the context is activated | |
347 * other supported protocols are silently discarded | |
348 * arbitration waits for a response to the context activation | |
349 */ | |
350 switch(ptype) | |
351 { | |
352 case DTI_PID_LCP: | |
353 sig_arb_lcp_packet_req(packet); | |
354 break; | |
355 | |
356 case DTI_PID_IPCP: | |
357 if(ppp_data->arb.last_ipcp) | |
358 { | |
359 MFREE_DESC2(ppp_data->arb.last_ipcp); | |
360 } | |
361 ppp_data->arb.last_ipcp = packet; | |
362 break; | |
363 | |
364 case DTI_PID_IP: | |
365 case DTI_PID_CTCP: | |
366 case DTI_PID_UTCP: | |
367 case DTI_PID_PAP: | |
368 case DTI_PID_CHAP: | |
369 arb_discard_packet(packet); | |
370 break; | |
371 default: | |
372 { | |
373 T_desc2* temp_desc; | |
374 | |
375 arb_get_protocol_reject (ptype, packet, &temp_desc); | |
376 sig_any_ftx_packet_req(DTI_PID_LCP, temp_desc); | |
377 } | |
378 break; | |
379 } | |
380 break; | |
381 case ARB_NCP_ESTABLISH: | |
382 case ARB_NCP_RECONF: | |
383 case ARB_NCP_MOD: | |
384 /* | |
385 * any protocol which is unsupported by the implementation must be | |
386 * returned in a Protocol-Reject packet | |
387 * LCP and IPCP are allowed during this phases | |
388 * other supported protocols are silently discarded | |
389 */ | |
390 switch(ptype) | |
391 { | |
392 case DTI_PID_LCP: | |
393 sig_arb_lcp_packet_req(packet); | |
394 break; | |
395 case DTI_PID_IPCP: | |
396 sig_arb_ncp_packet_req(packet); | |
397 break; | |
398 case DTI_PID_IP: | |
399 case DTI_PID_CTCP: | |
400 case DTI_PID_UTCP: | |
401 case DTI_PID_PAP: | |
402 case DTI_PID_CHAP: | |
403 arb_discard_packet(packet); | |
404 break; | |
405 default: | |
406 { | |
407 T_desc2* temp_desc; | |
408 arb_get_protocol_reject (ptype, packet, &temp_desc); | |
409 sig_any_ftx_packet_req(DTI_PID_LCP, temp_desc); | |
410 } | |
411 break; | |
412 } | |
413 break; | |
414 case ARB_IP: | |
415 /* | |
416 * any protocol which is unsupported by the implementation must be | |
417 * returned in a Protocol-Reject packet. If Van Jacobson is not | |
418 * negotiated then such packets must also be returned in a | |
419 * Protocol-Reject packet. | |
420 * LCP and IPCP are allowed during this phases | |
421 * other supported protocols are silently discarded | |
422 */ | |
423 switch(ptype) | |
424 { | |
425 case DTI_PID_LCP: | |
426 sig_arb_lcp_packet_req(packet); | |
427 break; | |
428 case DTI_PID_IPCP: | |
429 sig_arb_ncp_packet_req(packet); | |
430 break; | |
431 case DTI_PID_CHAP: | |
432 if(ppp_data->mode EQ PPP_CLIENT) | |
433 { | |
434 sig_arb_chap_packet_req(packet); | |
435 break; | |
436 } | |
437 /* else fall trough */ | |
438 case DTI_PID_IP: | |
439 case DTI_PID_PAP: | |
440 arb_discard_packet(packet); | |
441 break; | |
442 case DTI_PID_CTCP: | |
443 case DTI_PID_UTCP: | |
444 if(ppp_data->n_hc EQ PPP_HC_VJ) | |
445 { | |
446 arb_discard_packet(packet); | |
447 break; | |
448 } | |
449 /* fall through */ | |
450 default: | |
451 { | |
452 T_desc2* temp_desc; | |
453 | |
454 arb_get_protocol_reject (ptype, packet, &temp_desc); | |
455 sig_any_ftx_packet_req(DTI_PID_LCP, temp_desc); | |
456 } | |
457 break; | |
458 } | |
459 break; | |
460 default: | |
461 TRACE_ERROR( "SIG_PTX_ARB_PACKET_IND unexpected" ); | |
462 arb_discard_packet(packet); | |
463 break; | |
464 } | |
465 } /* sig_ptx_arb_packet_ind() */ | |
466 | |
467 | |
468 | |
469 /* | |
470 +------------------------------------------------------------------------------ | |
471 | Function : sig_lcp_arb_rpj_ind | |
472 +------------------------------------------------------------------------------ | |
473 | Description : Handles the internal signal SIG_LCP_ARB_RPJ_IND | |
474 | | |
475 | Parameters : ptype - type of rejected packet | |
476 | | |
477 +------------------------------------------------------------------------------ | |
478 */ | |
479 GLOBAL void sig_lcp_arb_rpj_ind (USHORT ptype) | |
480 { | |
481 TRACE_ISIG( "sig_lcp_arb_rpj_ind" ); | |
482 | |
483 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
484 { | |
485 case ARB_LCP_ESTABLISH: | |
486 case ARB_LCP_PDP: | |
487 case ARB_LCP_NCP: | |
488 case ARB_LCP_RECONF: | |
489 case ARB_LCP_MOD: | |
490 /* | |
491 * Protocol-Reject packets received in any other than the LCP Opened | |
492 * state should be silently discarded | |
493 */ | |
494 break; | |
495 case ARB_PAP_ESTABLISH: | |
496 case ARB_PAP_RECONF: | |
497 /* | |
498 * Close the connection if LCP or PAP is rejected. Otherwise the packet | |
499 * should be silently discarded. | |
500 */ | |
501 switch(ptype) | |
502 { | |
503 case DTI_PID_PAP: | |
504 /* | |
505 * set error code | |
506 */ | |
507 if(ppp_data->ppp_cause EQ 0) | |
508 ppp_data->ppp_cause = PPP_TERM_USE_AUTHED_FAILED; | |
509 /* fall through */ | |
510 case DTI_PID_LCP: | |
511 /* | |
512 * set error code | |
513 */ | |
514 if(ppp_data->ppp_cause EQ 0) | |
515 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
516 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
517 sig_arb_pap_down_req(); | |
518 sig_arb_lcp_close_req(); | |
519 break; | |
520 } | |
521 break; | |
522 case ARB_CHAP_ESTABLISH: | |
523 case ARB_CHAP_RECONF: | |
524 /* | |
525 * Close the connection if LCP or CHAP is rejected. Otherwise the packet | |
526 * should be silently discarded. | |
527 */ | |
528 switch(ptype) | |
529 { | |
530 case DTI_PID_CHAP: | |
531 /* | |
532 * set error code | |
533 */ | |
534 if(ppp_data->ppp_cause EQ 0) | |
535 ppp_data->ppp_cause = PPP_TERM_USE_AUTHED_FAILED; | |
536 /* fall through */ | |
537 case DTI_PID_LCP: | |
538 /* | |
539 * set error code | |
540 */ | |
541 if(ppp_data->ppp_cause EQ 0) | |
542 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
543 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
544 sig_arb_chap_down_req(); | |
545 sig_arb_lcp_close_req(); | |
546 break; | |
547 } | |
548 break; | |
549 case ARB_PDP_WAIT: | |
550 /* | |
551 * Close the connection if LCP is rejected. Otherwise the packet | |
552 * should be silently discarded. | |
553 */ | |
554 switch(ptype) | |
555 { | |
556 case DTI_PID_LCP: | |
557 /* | |
558 * set error code | |
559 */ | |
560 if(ppp_data->ppp_cause EQ 0) | |
561 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
562 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
563 sig_any_rt_srt_req(); | |
564 sig_arb_lcp_close_req(); | |
565 break; | |
566 } | |
567 break; | |
568 case ARB_PDP_SENT: | |
569 /* | |
570 * Close the connection if LCP is rejected. Otherwise the packet | |
571 * should be silently discarded. | |
572 */ | |
573 switch(ptype) | |
574 { | |
575 case DTI_PID_LCP: | |
576 /* | |
577 * set error code | |
578 */ | |
579 if(ppp_data->ppp_cause EQ 0) | |
580 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
581 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
582 if(ppp_data->arb.last_ipcp) | |
583 { | |
584 MFREE_DESC2(ppp_data->arb.last_ipcp); | |
585 ppp_data->arb.last_ipcp = NULL; | |
586 } | |
587 sig_arb_lcp_close_req(); | |
588 break; | |
589 } | |
590 break; | |
591 case ARB_NCP_ESTABLISH: | |
592 case ARB_NCP_RECONF: | |
593 case ARB_NCP_MOD: | |
594 /* | |
595 * Close the connection if LCP or IPCP is rejected. Otherwise the packet | |
596 * should be silently discarded. | |
597 */ | |
598 switch(ptype) | |
599 { | |
600 case DTI_PID_IPCP: | |
601 case DTI_PID_LCP: | |
602 /* | |
603 * set error code | |
604 */ | |
605 if(ppp_data->ppp_cause EQ 0) | |
606 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
607 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
608 sig_arb_ncp_down_req(); | |
609 sig_arb_lcp_close_req(); | |
610 break; | |
611 } | |
612 break; | |
613 case ARB_IP: | |
614 /* | |
615 * Close the connection if LCP, IPCP or IP is rejected. Also close the | |
616 * connection if (un)compressed TCP is rejected and header compression | |
617 * is switched on. Otherwise the packet should be silently discarded. | |
618 */ | |
619 switch(ptype) | |
620 { | |
621 case DTI_PID_CTCP: | |
622 case DTI_PID_UTCP: | |
623 { | |
624 UBYTE hc, msid; | |
625 ULONG ip, pdns, sdns; | |
626 /* | |
627 * determine whether header compression is switched on | |
628 */ | |
629 ncp_get_values (&hc, &msid, &ip, &pdns, &sdns); | |
630 if(hc NEQ PPP_HC_VJ) | |
631 break; | |
632 } | |
633 /* fall through */ | |
634 case DTI_PID_LCP: | |
635 case DTI_PID_IPCP: | |
636 case DTI_PID_IP: | |
637 /* | |
638 * set error code | |
639 */ | |
640 if(ppp_data->ppp_cause EQ 0) | |
641 ppp_data->ppp_cause = PPP_TERM_PROT_REJ_UNEXPECTED; | |
642 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
643 sig_arb_ftx_blocked_mode_req(); | |
644 sig_arb_ptx_blocked_mode_req(); | |
645 sig_arb_ncp_down_req(); | |
646 sig_arb_lcp_close_req(); | |
647 break; | |
648 } | |
649 break; | |
650 default: | |
651 TRACE_ERROR( "SIG_LCP_ARB_RPJ_IND unexpected" ); | |
652 break; | |
653 } | |
654 } /* sig_lcp_arb_rpj_ind() */ | |
655 | |
656 | |
657 | |
658 /* | |
659 +------------------------------------------------------------------------------ | |
660 | Function : sig_rt_arb_to_ind | |
661 +------------------------------------------------------------------------------ | |
662 | Description : Handles the internal signal SIG_RT_ARB_TO_IND | |
663 | | |
664 | Parameters : no parameters | |
665 | | |
666 +------------------------------------------------------------------------------ | |
667 */ | |
668 GLOBAL void sig_rt_arb_to_ind () | |
669 { | |
670 TRACE_ISIG( "sig_rt_arb_to_ind" ); | |
671 | |
672 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
673 { | |
674 case ARB_LCP_ESTABLISH: | |
675 case ARB_LCP_PDP: | |
676 case ARB_LCP_NCP: | |
677 case ARB_LCP_RECONF: | |
678 case ARB_LCP_MOD: | |
679 /* | |
680 * lcp time out | |
681 */ | |
682 sig_arb_lcp_to_req(); | |
683 break; | |
684 case ARB_PAP_ESTABLISH: | |
685 case ARB_PAP_RECONF: | |
686 sig_arb_pap_to_req(); | |
687 break; | |
688 case ARB_CHAP_ESTABLISH: | |
689 case ARB_CHAP_RECONF: | |
690 sig_arb_chap_to_req(); | |
691 break; | |
692 case ARB_PDP_WAIT: | |
693 { | |
694 UBYTE ap; | |
695 USHORT mru; | |
696 ULONG accm; | |
697 UBYTE pfc; | |
698 UBYTE acfc; | |
699 | |
700 TRACE_EVENT("waiting for IPCP Configure Request packet"); | |
701 /* | |
702 * determine authentication protocol | |
703 */ | |
704 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
705 switch(ap) | |
706 { | |
707 case PPP_AP_PAP: | |
708 sig_arb_pap_to_req(); | |
709 break; | |
710 case PPP_AP_CHAP: | |
711 sig_arb_chap_to_req(); | |
712 break; | |
713 default: | |
714 if(ppp_data->arb.to_counter EQ 0) | |
715 { | |
716 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
717 /* | |
718 * set error code | |
719 */ | |
720 if(ppp_data->ppp_cause EQ 0) | |
721 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_STARTED; | |
722 sig_arb_lcp_close_req(); | |
723 } | |
724 else | |
725 { | |
726 ppp_data->arb.to_counter--; | |
727 sig_any_rt_rrt_req(); | |
728 } | |
729 break; | |
730 } | |
731 | |
732 } | |
733 break; | |
734 case ARB_NCP_ESTABLISH: | |
735 case ARB_NCP_RECONF: | |
736 case ARB_NCP_MOD: | |
737 /* | |
738 * ncp time out | |
739 */ | |
740 sig_arb_ncp_to_req(); | |
741 break; | |
742 case ARB_IP: | |
743 if(ppp_data->mode EQ PPP_CLIENT) | |
744 { | |
745 sig_arb_chap_to_req(); | |
746 break; | |
747 } | |
748 /* else fall trough */ | |
749 default: | |
750 TRACE_ERROR( "SIG_RT_ARB_TO_IND unexpected" ); | |
751 break; | |
752 } | |
753 } /* sig_rt_arb_to_ind() */ | |
754 | |
755 | |
756 | |
757 /* | |
758 +------------------------------------------------------------------------------ | |
759 | Function : sig_any_arb_tlf_ind | |
760 +------------------------------------------------------------------------------ | |
761 | Description : Handles the internal signal SIG_ANY_ARB_TLF_IND | |
762 | | |
763 | Parameters : no parameters | |
764 | | |
765 +------------------------------------------------------------------------------ | |
766 */ | |
767 GLOBAL void sig_any_arb_tlf_ind () | |
768 { | |
769 TRACE_ISIG( "sig_any_arb_tlf_ind" ); | |
770 | |
771 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
772 { | |
773 case ARB_LCP_ESTABLISH: | |
774 case ARB_LCP_PDP: | |
775 case ARB_LCP_NCP: | |
776 case ARB_LCP_RECONF: | |
777 case ARB_LCP_MOD: | |
778 if(ppp_data->arb.last_ipcp) | |
779 { | |
780 MFREE_DESC2(ppp_data->arb.last_ipcp); | |
781 ppp_data->arb.last_ipcp = NULL; | |
782 } | |
783 /* | |
784 * send a PPP_TERMINATE_IND | |
785 */ | |
786 { | |
787 PALLOC (ppp_terminate_ind, PPP_TERMINATE_IND); | |
788 SET_STATE( PPP_SERVICE_ARB, ARB_DEAD ); | |
789 sig_arb_ncp_down_req(); | |
790 sig_arb_pap_down_req(); | |
791 sig_arb_chap_down_req(); | |
792 sig_arb_lcp_down_req(); | |
793 sig_arb_ptx_dead_mode_req(); | |
794 sig_arb_ftx_dead_mode_req(); | |
795 arb_dti_close_prot_ind(); | |
796 arb_dti_close_peer_ind(); | |
797 | |
798 /* | |
799 * set error code | |
800 */ | |
801 if(ppp_data->ppp_cause EQ 0) | |
802 ppp_data->ppp_cause = PPP_TERM_PROT_ERROR_UNSPEC; | |
803 ppp_terminate_ind->ppp_cause = ppp_data->ppp_cause; | |
804 PSEND (hCommMMI, ppp_terminate_ind); | |
805 } | |
806 break; | |
807 case ARB_PDP_WAIT: | |
808 /* | |
809 * set error code | |
810 */ | |
811 if(ppp_data->ppp_cause EQ 0) | |
812 ppp_data->ppp_cause = PPP_TERM_IPCP_NOT_STARTED; | |
813 /* fall through */ | |
814 case ARB_PAP_ESTABLISH: | |
815 case ARB_PAP_RECONF: | |
816 case ARB_CHAP_ESTABLISH: | |
817 case ARB_CHAP_RECONF: | |
818 /* | |
819 * set error code | |
820 */ | |
821 if(ppp_data->ppp_cause EQ 0) | |
822 ppp_data->ppp_cause = PPP_TERM_USE_AUTHED_FAILED; | |
823 /* fall through */ | |
824 case ARB_NCP_ESTABLISH: | |
825 case ARB_NCP_RECONF: | |
826 case ARB_NCP_MOD: | |
827 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
828 sig_arb_lcp_close_req(); | |
829 break; | |
830 default: | |
831 TRACE_ERROR( "SIG_ANY_ARB_TLF_IND unexpected" ); | |
832 break; | |
833 } | |
834 } /* sig_any_arb_tlf_ind() */ | |
835 | |
836 | |
837 | |
838 /* | |
839 +------------------------------------------------------------------------------ | |
840 | Function : sig_any_arb_tlu_ind | |
841 +------------------------------------------------------------------------------ | |
842 | Description : Handles the internal signal SIG_ANY_ARB_TLU_IND | |
843 | | |
844 | Parameters : no parameters | |
845 | | |
846 +------------------------------------------------------------------------------ | |
847 */ | |
848 GLOBAL void sig_any_arb_tlu_ind () | |
849 { | |
850 | |
851 TRACE_ISIG( "sig_any_arb_tlu_ind" ); | |
852 | |
853 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
854 { | |
855 case ARB_LCP_ESTABLISH: | |
856 { | |
857 UBYTE ap; | |
858 USHORT mru; | |
859 ULONG accm; | |
860 UBYTE pfc; | |
861 UBYTE acfc; | |
862 | |
863 /* | |
864 * get the LCP values and configure the frame transmission | |
865 */ | |
866 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
867 sig_arb_ftx_parameters_req(accm, pfc, acfc); | |
868 | |
869 switch(ap) | |
870 { | |
871 case PPP_AP_PAP: | |
872 /* | |
873 * start PAP | |
874 */ | |
875 SET_STATE( PPP_SERVICE_ARB, ARB_PAP_ESTABLISH ); | |
876 sig_arb_pap_open_req(); | |
877 break; | |
878 case PPP_AP_CHAP: | |
879 /* | |
880 * start CHAP | |
881 */ | |
882 SET_STATE( PPP_SERVICE_ARB, ARB_CHAP_ESTABLISH ); | |
883 sig_arb_chap_open_req(); | |
884 break; | |
885 default: | |
886 if (ppp_data->mode EQ PPP_CLIENT) | |
887 { | |
888 /* | |
889 * start IPCP modification | |
890 */ | |
891 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_ESTABLISH ); | |
892 sig_arb_ncp_open_req(); | |
893 } | |
894 else | |
895 { | |
896 | |
897 /* | |
898 * wait for an IPCP Configure-Request | |
899 */ | |
900 SET_STATE( PPP_SERVICE_ARB, ARB_PDP_WAIT ); | |
901 /* | |
902 * ensure that authentication will not negotiated next time | |
903 */ | |
904 sig_arb_lcp_modify_ap_req(PPP_AP_NO); | |
905 ppp_data->arb.to_counter=ppp_data->mc; | |
906 if(ppp_data->arb.to_counter > 0) | |
907 ppp_data->arb.to_counter--; | |
908 sig_any_rt_rrt_req(); | |
909 } | |
910 break; | |
911 } | |
912 } | |
913 break; | |
914 case ARB_LCP_PDP: | |
915 /* | |
916 * this will happen only in server mode | |
917 */ | |
918 { | |
919 UBYTE ap; | |
920 USHORT mru; | |
921 ULONG accm; | |
922 UBYTE pfc; | |
923 UBYTE acfc; | |
924 | |
925 /* | |
926 * wait for the answer of context activation | |
927 */ | |
928 SET_STATE( PPP_SERVICE_ARB, ARB_PDP_SENT ); | |
929 | |
930 /* | |
931 * get the LCP values and configure the frame transmission | |
932 */ | |
933 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
934 sig_arb_ftx_parameters_req(accm, pfc, acfc); | |
935 } | |
936 break; | |
937 case ARB_LCP_NCP: | |
938 /* | |
939 * this will happen only in server mode | |
940 */ | |
941 { | |
942 UBYTE ap; | |
943 USHORT mru; | |
944 ULONG accm; | |
945 UBYTE pfc; | |
946 UBYTE acfc; | |
947 T_desc2* temp_desc; | |
948 | |
949 /* | |
950 * start IPCP establishment | |
951 */ | |
952 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_ESTABLISH ); | |
953 | |
954 /* | |
955 * get the LCP values and configure the frame transmission | |
956 */ | |
957 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
958 sig_arb_ftx_parameters_req(accm, pfc, acfc); | |
959 | |
960 sig_arb_ncp_open_req(); | |
961 if(ppp_data->arb.last_ipcp) | |
962 { | |
963 temp_desc = ppp_data->arb.last_ipcp; | |
964 ppp_data->arb.last_ipcp = NULL; | |
965 sig_arb_ncp_packet_req(temp_desc); | |
966 } | |
967 } | |
968 break; | |
969 case ARB_LCP_RECONF: | |
970 { | |
971 UBYTE ap; | |
972 USHORT mru; | |
973 ULONG accm; | |
974 UBYTE pfc; | |
975 UBYTE acfc; | |
976 | |
977 /* | |
978 * get the LCP values and configure the frame transmission | |
979 */ | |
980 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
981 sig_arb_ftx_parameters_req(accm, pfc, acfc); | |
982 | |
983 if(ppp_data->mode EQ PPP_CLIENT) | |
984 switch(ap) | |
985 { | |
986 case PPP_AP_PAP: | |
987 /* | |
988 * start PAP | |
989 */ | |
990 SET_STATE( PPP_SERVICE_ARB, ARB_PAP_RECONF ); | |
991 sig_arb_pap_open_req(); | |
992 break; | |
993 case PPP_AP_CHAP: | |
994 /* | |
995 * start CHAP | |
996 */ | |
997 SET_STATE( PPP_SERVICE_ARB, ARB_CHAP_RECONF ); | |
998 sig_arb_chap_open_req(); | |
999 break; | |
1000 default: | |
1001 /* | |
1002 * start IPCP modification | |
1003 */ | |
1004 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
1005 sig_arb_ncp_open_req(); | |
1006 break; | |
1007 } | |
1008 else | |
1009 { | |
1010 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
1011 sig_arb_ncp_open_req(); | |
1012 } | |
1013 } | |
1014 break; | |
1015 case ARB_LCP_MOD: | |
1016 /* | |
1017 * this will happen only in server mode | |
1018 */ | |
1019 { | |
1020 UBYTE ap; | |
1021 USHORT mru; | |
1022 ULONG accm; | |
1023 UBYTE pfc; | |
1024 UBYTE acfc; | |
1025 | |
1026 /* | |
1027 * start IPCP modification | |
1028 */ | |
1029 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_MOD ); | |
1030 | |
1031 /* | |
1032 * get the LCP values and configure the frame transmission | |
1033 */ | |
1034 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
1035 sig_arb_ftx_parameters_req(accm, pfc, acfc); | |
1036 | |
1037 sig_arb_ncp_open_req(); | |
1038 } | |
1039 break; | |
1040 case ARB_PAP_ESTABLISH: | |
1041 case ARB_CHAP_ESTABLISH: | |
1042 if (ppp_data->mode EQ PPP_CLIENT) | |
1043 { | |
1044 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_ESTABLISH ); | |
1045 /* | |
1046 * reset error code | |
1047 */ | |
1048 ppp_data->ppp_cause = 0; | |
1049 /* | |
1050 * start IPCP | |
1051 */ | |
1052 sig_arb_ncp_open_req(); | |
1053 } | |
1054 else | |
1055 { | |
1056 /* | |
1057 * PPP_SERVER | |
1058 * wait for an IPCP Configure-Request | |
1059 */ | |
1060 SET_STATE( PPP_SERVICE_ARB, ARB_PDP_WAIT ); | |
1061 /* | |
1062 * ensure that authentication will not negotiated next time | |
1063 */ | |
1064 sig_arb_lcp_modify_ap_req(PPP_AP_NO); | |
1065 } | |
1066 break; | |
1067 case ARB_PAP_RECONF: | |
1068 case ARB_CHAP_RECONF: | |
1069 /* | |
1070 * this will happen only in client mode | |
1071 */ | |
1072 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
1073 sig_arb_ncp_open_req(); | |
1074 break; | |
1075 case ARB_NCP_ESTABLISH: | |
1076 { | |
1077 UBYTE ap; | |
1078 USHORT mru; | |
1079 ULONG accm; | |
1080 UBYTE pfc; | |
1081 UBYTE acfc; | |
1082 UBYTE ppp_hc; | |
1083 UBYTE msid; | |
1084 ULONG ip; | |
1085 ULONG pdns; | |
1086 ULONG sdns; | |
1087 | |
1088 PALLOC (ppp_establish_cnf, PPP_ESTABLISH_CNF); | |
1089 SET_STATE( PPP_SERVICE_ARB, ARB_IP ); | |
1090 /* | |
1091 * get the LCP and IPCP values and store it | |
1092 * into the PPP_ESTABLISH_CNF primitive | |
1093 */ | |
1094 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
1095 ncp_get_values(&ppp_hc, &msid, &ip, &pdns, &sdns); | |
1096 | |
1097 ppp_data->n_hc = ppp_hc; | |
1098 | |
1099 sig_arb_ftx_ready_mode_req(); | |
1100 sig_arb_ptx_ready_mode_req(); | |
1101 | |
1102 ppp_establish_cnf->mru=mru; | |
1103 ppp_establish_cnf->ppp_hc=ppp_hc; | |
1104 ppp_establish_cnf->msid=msid; | |
1105 ppp_establish_cnf->ip=ip; | |
1106 ppp_establish_cnf->dns1=pdns; | |
1107 ppp_establish_cnf->dns2=sdns; | |
1108 | |
1109 TRACE_EVENT( "PPP Established" ); | |
1110 | |
1111 PSEND (hCommMMI, ppp_establish_cnf); | |
1112 } | |
1113 break; | |
1114 case ARB_NCP_RECONF: | |
1115 { | |
1116 UBYTE ppp_hc; | |
1117 UBYTE msid; | |
1118 ULONG ip; | |
1119 ULONG pdns; | |
1120 ULONG sdns; | |
1121 | |
1122 SET_STATE( PPP_SERVICE_ARB, ARB_IP ); | |
1123 /* | |
1124 * get IPCP values to set PTX value | |
1125 */ | |
1126 ncp_get_values(&ppp_hc, &msid, &ip, &pdns, &sdns); | |
1127 | |
1128 ppp_data->n_hc = ppp_hc; | |
1129 | |
1130 sig_arb_ftx_ready_mode_req(); | |
1131 sig_arb_ptx_ready_mode_req(); | |
1132 } | |
1133 break; | |
1134 case ARB_NCP_MOD: | |
1135 /* | |
1136 * this will happen only in server mode | |
1137 */ | |
1138 { | |
1139 UBYTE ppp_hc; | |
1140 UBYTE msid; | |
1141 ULONG ip; | |
1142 ULONG pdns; | |
1143 ULONG sdns; | |
1144 | |
1145 PALLOC (ppp_modification_cnf, PPP_MODIFICATION_CNF); | |
1146 SET_STATE( PPP_SERVICE_ARB, ARB_IP ); | |
1147 /* | |
1148 * get IPCP values and store it into | |
1149 * the PPP_MODIFICATION_CNF primitive | |
1150 */ | |
1151 ncp_get_values(&ppp_hc, &msid, &ip, &pdns, &sdns); | |
1152 | |
1153 ppp_data->n_hc = ppp_hc; | |
1154 | |
1155 sig_arb_ftx_ready_mode_req(); | |
1156 sig_arb_ptx_ready_mode_req(); | |
1157 | |
1158 ppp_modification_cnf->ppp_hc=ppp_hc; | |
1159 ppp_modification_cnf->msid=msid; | |
1160 PSEND (hCommMMI, ppp_modification_cnf); | |
1161 } | |
1162 break; | |
1163 | |
1164 case ARB_IP: | |
1165 if (ppp_data->mode EQ PPP_CLIENT) | |
1166 /* | |
1167 * do nothing, funct. was called after CHAP re-authentication | |
1168 */ | |
1169 break; | |
1170 /* else fall through */ | |
1171 | |
1172 default: | |
1173 TRACE_ERROR( "SIG_ANY_ARB_TLU_IND unexpected" ); | |
1174 break; | |
1175 } | |
1176 } /* sig_any_arb_tlu_ind() */ | |
1177 | |
1178 | |
1179 | |
1180 /* | |
1181 +------------------------------------------------------------------------------ | |
1182 | Function : sig_lcp_arb_tld_ind | |
1183 +------------------------------------------------------------------------------ | |
1184 | Description : Handles the internal signal SIG_LCP_ARB_TLD_IND | |
1185 | | |
1186 | Parameters : no parameters | |
1187 | | |
1188 +------------------------------------------------------------------------------ | |
1189 */ | |
1190 GLOBAL void sig_lcp_arb_tld_ind () | |
1191 { | |
1192 TRACE_ISIG( "sig_lcp_arb_tld_ind" ); | |
1193 | |
1194 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
1195 { | |
1196 case ARB_PAP_ESTABLISH: | |
1197 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1198 if((ppp_data->ppp_cause EQ 0) && (ppp_data->mode EQ PPP_CLIENT)) | |
1199 ppp_data->ppp_cause = PPP_TERM_USE_AUTHED_FAILED; | |
1200 sig_arb_pap_down_req(); | |
1201 break; | |
1202 case ARB_CHAP_ESTABLISH: | |
1203 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1204 if((ppp_data->ppp_cause EQ 0) && (ppp_data->mode EQ PPP_CLIENT)) | |
1205 ppp_data->ppp_cause = PPP_TERM_USE_AUTHED_FAILED; | |
1206 sig_arb_chap_down_req(); | |
1207 break; | |
1208 case ARB_PAP_RECONF: | |
1209 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1210 sig_arb_pap_down_req(); | |
1211 break; | |
1212 case ARB_CHAP_RECONF: | |
1213 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1214 sig_arb_chap_down_req(); | |
1215 break; | |
1216 case ARB_PDP_WAIT: | |
1217 /* | |
1218 * this will happen only in server mode | |
1219 */ | |
1220 { | |
1221 UBYTE ap; | |
1222 USHORT mru; | |
1223 ULONG accm; | |
1224 UBYTE pfc; | |
1225 UBYTE acfc; | |
1226 | |
1227 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1228 /* | |
1229 * determine authentication protocol | |
1230 */ | |
1231 lcp_get_values(&ap, &mru, &accm, &pfc, &acfc); | |
1232 switch(ap) | |
1233 { | |
1234 case PPP_AP_PAP: | |
1235 sig_arb_pap_down_req(); | |
1236 break; | |
1237 case PPP_AP_CHAP: | |
1238 sig_arb_chap_down_req(); | |
1239 break; | |
1240 default: | |
1241 sig_any_rt_srt_req(); | |
1242 break; | |
1243 } | |
1244 } | |
1245 break; | |
1246 case ARB_PDP_SENT: | |
1247 /* | |
1248 * this will happen only in server mode | |
1249 */ | |
1250 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_PDP ); | |
1251 break; | |
1252 case ARB_NCP_ESTABLISH: | |
1253 if(ppp_data->mode EQ PPP_CLIENT) | |
1254 { | |
1255 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1256 } | |
1257 else | |
1258 { | |
1259 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_NCP ); | |
1260 } | |
1261 /* | |
1262 * get ncp down | |
1263 */ | |
1264 sig_arb_ncp_down_req(); | |
1265 break; | |
1266 case ARB_NCP_RECONF: | |
1267 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1268 /* | |
1269 * get ncp down | |
1270 */ | |
1271 sig_arb_ncp_down_req(); | |
1272 break; | |
1273 case ARB_NCP_MOD: | |
1274 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_MOD ); | |
1275 /* | |
1276 * get ncp down | |
1277 */ | |
1278 sig_arb_ncp_down_req(); | |
1279 break; | |
1280 case ARB_IP: | |
1281 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1282 sig_arb_ftx_blocked_mode_req(); | |
1283 sig_arb_ptx_blocked_mode_req(); | |
1284 /* | |
1285 * get ncp down | |
1286 */ | |
1287 sig_arb_ncp_down_req(); | |
1288 break; | |
1289 default: | |
1290 TRACE_ERROR( "SIG_LCP_ARB_TLD_IND unexpected" ); | |
1291 break; | |
1292 } | |
1293 } /* sig_lcp_arb_tld_ind() */ | |
1294 | |
1295 | |
1296 | |
1297 /* | |
1298 +------------------------------------------------------------------------------ | |
1299 | Function : sig_ncp_arb_tld_ind | |
1300 +------------------------------------------------------------------------------ | |
1301 | Description : Handles the internal signal SIG_NCP_ARB_TLD_IND | |
1302 | | |
1303 | Parameters : no parameters | |
1304 | | |
1305 +------------------------------------------------------------------------------ | |
1306 */ | |
1307 GLOBAL void sig_ncp_arb_tld_ind () | |
1308 { | |
1309 TRACE_ISIG( "sig_ncp_arb_tld_ind" ); | |
1310 | |
1311 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
1312 { | |
1313 case ARB_IP: | |
1314 SET_STATE( PPP_SERVICE_ARB, ARB_NCP_RECONF ); | |
1315 sig_arb_ftx_blocked_mode_req(); | |
1316 sig_arb_ptx_blocked_mode_req(); | |
1317 break; | |
1318 default: | |
1319 TRACE_ERROR( "SIG_NCP_ARB_TLD_IND unexpected" ); | |
1320 break; | |
1321 } | |
1322 } /* sig_ncp_arb_tld_ind() */ | |
1323 | |
1324 | |
1325 | |
1326 /* | |
1327 +------------------------------------------------------------------------------ | |
1328 | Function : sig_frx_arb_escape_ind | |
1329 +------------------------------------------------------------------------------ | |
1330 | Description : Handles the internal signal SIG_FRX_ARB_ESCAPE_IND | |
1331 | | |
1332 | Parameters : no parameters | |
1333 | | |
1334 +------------------------------------------------------------------------------ | |
1335 */ | |
1336 GLOBAL void sig_frx_arb_escape_ind () | |
1337 { | |
1338 /* | |
1339 * free all PPP resources and finish | |
1340 */ | |
1341 PALLOC (ppp_terminate_ind, PPP_TERMINATE_IND); | |
1342 | |
1343 TRACE_ISIG( "sig_frx_arb_escape_ind" ); | |
1344 | |
1345 TRACE_EVENT( "Peer requested Termination by DTR drop or +++" ); | |
1346 | |
1347 SET_STATE( PPP_SERVICE_ARB, ARB_DEAD ); | |
1348 if(ppp_data->arb.last_ipcp) | |
1349 { | |
1350 MFREE_DESC2(ppp_data->arb.last_ipcp); | |
1351 ppp_data->arb.last_ipcp = NULL; | |
1352 } | |
1353 sig_arb_ncp_down_req(); | |
1354 sig_arb_pap_down_req(); | |
1355 sig_arb_chap_down_req(); | |
1356 sig_arb_lcp_down_req(); | |
1357 sig_arb_ptx_dead_mode_req(); | |
1358 sig_arb_ftx_dead_mode_req(); | |
1359 arb_dti_close_prot_ind(); | |
1360 arb_dti_close_peer_ind(); | |
1361 | |
1362 /* | |
1363 * set error code | |
1364 */ | |
1365 | |
1366 if(ppp_data->ppp_cause EQ 0) | |
1367 ppp_data->ppp_cause = PPP_TERM_OK_PEER; | |
1368 ppp_terminate_ind->ppp_cause = ppp_data->ppp_cause; | |
1369 PSEND (hCommMMI, ppp_terminate_ind); | |
1370 } /* sig_frx_arb_escape_ind() */ | |
1371 | |
1372 /* | |
1373 +------------------------------------------------------------------------------ | |
1374 | Function : sig_dti_arb_connection_opened_ind | |
1375 +------------------------------------------------------------------------------ | |
1376 | Description : Handles the internal signal SIG_DTI_ARB_CONNECTION_OPENED_IND | |
1377 | | |
1378 | Parameters : *hDTI - Handle for DTI Database | |
1379 | instance - DTI Instance | |
1380 | inter_face - DTI Interface | |
1381 | channel - DTI Channel | |
1382 | | |
1383 +------------------------------------------------------------------------------ | |
1384 */ | |
1385 | |
1386 GLOBAL void sig_dti_arb_connection_opened_ind(DTI_HANDLE hDTI, | |
1387 U8 instance, | |
1388 U8 inter_face, | |
1389 U8 channel) | |
1390 { | |
1391 TRACE_ISIG("sig_dti_arb_connection_opened_ind"); | |
1392 | |
1393 /* | |
1394 * Ok - connected to a DTI Channel | |
1395 */ | |
1396 switch (inter_face) | |
1397 { | |
1398 case PROT_LAYER: | |
1399 { | |
1400 PALLOC(dti_connected_ind, PPP_DTI_CONNECTED_IND); | |
1401 dti_connected_ind->connected_direction = PPP_DTI_CONN_PROT; | |
1402 ppp_data->arb.dti_connect_state_prot = DTI_IDLE; | |
1403 PSEND (hCommMMI, dti_connected_ind); | |
1404 } | |
1405 sig_arb_prx_dti_connected_req(); | |
1406 break; | |
1407 | |
1408 case PEER_LAYER: | |
1409 { | |
1410 PALLOC(dti_connected_ind, PPP_DTI_CONNECTED_IND); | |
1411 dti_connected_ind->connected_direction = PPP_DTI_CONN_PEER; | |
1412 ppp_data->arb.dti_connect_state_peer = DTI_IDLE; | |
1413 PSEND (hCommMMI, dti_connected_ind); | |
1414 } | |
1415 sig_arb_frx_dti_connected_req(); | |
1416 | |
1417 switch (GET_STATE( PPP_SERVICE_ARB ) ) | |
1418 { | |
1419 case ARB_DEAD: | |
1420 switch (ppp_data->mode) | |
1421 { | |
1422 case PPP_TRANSPARENT: | |
1423 /* | |
1424 * transparent is only ready after both dti connections | |
1425 * have been acknowledged open | |
1426 */ | |
1427 break; | |
1428 | |
1429 case PPP_SERVER: | |
1430 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1431 TRACE_EVENT("DTI CONNECTED START ARB_LCP_ESTABLISH SERVER"); | |
1432 sig_arb_lcp_open_req(); | |
1433 break; | |
1434 | |
1435 case PPP_CLIENT: | |
1436 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_ESTABLISH ); | |
1437 TRACE_EVENT("DTI CONNECTED START ARB_LCP_ESTABLISH CLIENT"); | |
1438 sig_arb_lcp_open_req(); | |
1439 break; | |
1440 | |
1441 default: | |
1442 TRACE_ERROR( "PPP_ESTABLISH_REQ with invalid parameter: mode" ); | |
1443 break; | |
1444 }/* switch (ppp_data->mode) */ | |
1445 break; | |
1446 | |
1447 default: | |
1448 TRACE_ERROR( "DTI signal unexpected" ); | |
1449 break; | |
1450 }/* switch( GET_STATE( PPP_SERVICE_ARB ) ) */ | |
1451 break; | |
1452 | |
1453 default: | |
1454 TRACE_ERROR( "DTI direction unknown" ); | |
1455 break; | |
1456 }/* switch (inter_face) */ | |
1457 | |
1458 /* | |
1459 * Start transparent mode if both DTI channels are connected | |
1460 */ | |
1461 if( | |
1462 (ppp_data->mode EQ PPP_TRANSPARENT) AND | |
1463 (ppp_data->arb.dti_connect_state_prot EQ DTI_IDLE) AND | |
1464 (ppp_data->arb.dti_connect_state_peer EQ DTI_IDLE) AND | |
1465 (GET_STATE( PPP_SERVICE_ARB ) EQ ARB_DEAD) | |
1466 ) | |
1467 { | |
1468 SET_STATE( PPP_SERVICE_ARB, ARB_TRANSPARENT ); | |
1469 TRACE_EVENT("DTI CONNECTED TRANSPARENT"); | |
1470 { | |
1471 PALLOC (ppp_establish_cnf, PPP_ESTABLISH_CNF); | |
1472 #ifdef _SIMULATION_ | |
1473 ppp_establish_cnf->mru=PPP_MRU_DEFAULT; | |
1474 ppp_establish_cnf->ppp_hc=PPP_HC_OFF; | |
1475 ppp_establish_cnf->msid=0; | |
1476 ppp_establish_cnf->ip=PPP_IP_DYNAMIC; | |
1477 ppp_establish_cnf->dns1=PPP_DNS1_DYNAMIC; | |
1478 ppp_establish_cnf->dns2=PPP_DNS2_DYNAMIC; | |
1479 #endif /* _SIMULATION_ */ | |
1480 PSEND (hCommMMI, ppp_establish_cnf); | |
1481 } | |
1482 sig_arb_ptx_transparent_mode_req(); | |
1483 sig_arb_ftx_transparent_mode_req(); | |
1484 } | |
1485 } | |
1486 | |
1487 /* | |
1488 +------------------------------------------------------------------------------ | |
1489 | Function : sig_dti_arb_connection_closed_ind | |
1490 +------------------------------------------------------------------------------ | |
1491 | Description : Handles the internal signal | |
1492 | SIG_DTI_FTX_ARB_CONNECTION_CLOSED_IND. | |
1493 | | |
1494 | Parameters : *hDTI - Handle for DTI Database | |
1495 | instance - DTI Instance | |
1496 | inter_face - DTI Interface | |
1497 | channel - DTI Channel | |
1498 | | |
1499 +------------------------------------------------------------------------------ | |
1500 */ | |
1501 GLOBAL void sig_dti_arb_connection_closed_ind (DTI_HANDLE hDTI, | |
1502 U8 instance, | |
1503 U8 inter_face, | |
1504 U8 channel) | |
1505 { | |
1506 TRACE_ISIG("sig_dti_arb_connection_closed_ind"); | |
1507 | |
1508 switch( GET_STATE( PPP_SERVICE_ARB ) ) | |
1509 { | |
1510 case ARB_PAP_ESTABLISH: | |
1511 case ARB_PAP_RECONF: | |
1512 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1513 sig_arb_pap_down_req(); | |
1514 break; | |
1515 case ARB_CHAP_ESTABLISH: | |
1516 case ARB_CHAP_RECONF: | |
1517 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1518 sig_arb_chap_down_req(); | |
1519 break; | |
1520 case ARB_PDP_WAIT: | |
1521 SET_STATE( PPP_SERVICE_ARB, ARB_LCP_RECONF ); | |
1522 sig_any_rt_srt_req(); | |
1523 break; | |
1524 } | |
1525 | |
1526 /* | |
1527 * free all PPP resources and finish | |
1528 */ | |
1529 { | |
1530 PALLOC (ppp_terminate_ind, PPP_TERMINATE_IND); | |
1531 | |
1532 SET_STATE( PPP_SERVICE_ARB, ARB_DEAD ); | |
1533 sig_arb_ncp_down_req(); | |
1534 sig_arb_pap_down_req(); | |
1535 sig_arb_chap_down_req(); | |
1536 sig_arb_lcp_down_req(); | |
1537 sig_arb_ptx_dead_mode_req(); | |
1538 sig_arb_ftx_dead_mode_req(); | |
1539 | |
1540 if(ppp_data->ppp_cause EQ 0) | |
1541 ppp_data->ppp_cause = PPP_TERM_NO_CHANNEL; | |
1542 ppp_terminate_ind->ppp_cause = ppp_data->ppp_cause; | |
1543 PSEND (hCommMMI, ppp_terminate_ind); | |
1544 } | |
1545 | |
1546 /* | |
1547 * Be shure all DTI channels are closed | |
1548 */ | |
1549 arb_dti_close_prot_ind(); | |
1550 arb_dti_close_peer_ind(); | |
1551 } |