RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/auth.c,v
retrieving revision 1.5
diff -u -r1.5 auth.c
|
|
|
249 | 249 | link_terminated(unit) |
250 | 250 | int unit; |
251 | 251 | { |
252 | | if (phase == PHASE_DEAD) |
| 252 | if (pppd_phase == PHASE_DEAD) |
253 | 253 | return; |
254 | 254 | if (pap_logout_hook) { |
255 | 255 | pap_logout_hook(); |
… |
… |
|
283 | 283 | } |
284 | 284 | num_np_open = 0; |
285 | 285 | num_np_up = 0; |
286 | | if (phase != PHASE_DEAD) |
| 286 | if (pppd_phase != PHASE_DEAD) |
287 | 287 | new_phase(PHASE_TERMINATE); |
288 | 288 | } |
289 | 289 | |
… |
… |
|
323 | 323 | } else if (!wo->neg_upap || !null_login(unit)) { |
324 | 324 | warn("peer refused to authenticate: terminating link"); |
325 | 325 | lcp_close(unit, "peer refused to authenticate"); |
326 | | status = EXIT_PEER_AUTH_FAILED; |
| 326 | pppd_status = EXIT_PEER_AUTH_FAILED; |
327 | 327 | return; |
328 | 328 | } |
329 | 329 | } |
… |
… |
|
425 | 425 | * Authentication failure: take the link down |
426 | 426 | */ |
427 | 427 | lcp_close(unit, "Authentication failed"); |
428 | | status = EXIT_PEER_AUTH_FAILED; |
| 428 | pppd_status = EXIT_PEER_AUTH_FAILED; |
429 | 429 | } |
430 | 430 | |
431 | 431 | /* |
… |
… |
|
483 | 483 | * authentication secrets. |
484 | 484 | */ |
485 | 485 | lcp_close(unit, "Failed to authenticate ourselves to peer"); |
486 | | status = EXIT_AUTH_TOPEER_FAILED; |
| 486 | pppd_status = EXIT_AUTH_TOPEER_FAILED; |
487 | 487 | } |
488 | 488 | |
489 | 489 | /* |
… |
… |
|
531 | 531 | /* |
532 | 532 | * At this point we consider that the link has come up successfully. |
533 | 533 | */ |
534 | | status = EXIT_OK; |
| 534 | pppd_status = EXIT_OK; |
535 | 535 | unsuccess = 0; |
536 | 536 | new_phase(PHASE_RUNNING); |
537 | 537 | |
… |
… |
|
603 | 603 | notice("Terminating connection due to lack of activity."); |
604 | 604 | lcp_close(0, "Link inactive"); |
605 | 605 | need_holdoff = 0; |
606 | | status = EXIT_IDLE_TIMEOUT; |
| 606 | pppd_status = EXIT_IDLE_TIMEOUT; |
607 | 607 | } else { |
608 | 608 | TIMEOUT(check_idle, NULL, tlim); |
609 | 609 | } |
… |
… |
|
618 | 618 | { |
619 | 619 | info("Connect time expired"); |
620 | 620 | lcp_close(0, "Connect time expired"); /* Close connection */ |
621 | | status = EXIT_CONNECT_TIME; |
| 621 | pppd_status = EXIT_CONNECT_TIME; |
622 | 622 | } |
623 | 623 | |
624 | 624 | /* |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/chat.c,v
retrieving revision 1.7
diff -u -r1.7 chat.c
|
|
|
140 | 140 | #endif |
141 | 141 | /*************** Micro getopt() *********************************************/ |
142 | 142 | |
143 | | char *program_name; |
144 | | |
145 | 143 | #define MAX_ABORTS 16 |
146 | 144 | #define MAX_REPORTS 16 |
147 | 145 | #define DEFAULT_CHAT_TIMEOUT 45 |
148 | 146 | #define MAX_TIMEOUTS 10 |
149 | 147 | |
150 | | int echo = 0; |
151 | | int quiet = 0; |
152 | | int report = 0; |
153 | | int use_env = 0; |
154 | | int exit_code = 0; |
155 | | char *report_file = (char *) 0; |
156 | | char *chat_file = (char *) 0; |
157 | | char *phone_num = (char *) 0; |
158 | | char *phone_num2 = (char *) 0; |
| 148 | static int echo = 0; |
| 149 | static int quiet = 0; |
| 150 | static int use_env = 0; |
| 151 | static int exit_code = 0; |
| 152 | static char *phone_num = (char *) 0; |
| 153 | static char *phone_num2 = (char *) 0; |
159 | 154 | static int ttyfd; |
160 | 155 | static int timeout = DEFAULT_CHAT_TIMEOUT; |
161 | 156 | |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/demand.c,v
retrieving revision 1.3
diff -u -r1.3 demand.c
|
|
|
45 | 45 | |
46 | 46 | static const char rcsid[] = RCSID; |
47 | 47 | |
48 | | char *frame; |
49 | | int framelen; |
50 | | int framemax; |
51 | | int escape_flag; |
52 | | int flush_flag; |
53 | | int fcs; |
| 48 | static char *frame; |
| 49 | static int framelen; |
| 50 | static int framemax; |
| 51 | static int escape_flag; |
| 52 | static int flush_flag; |
| 53 | static int fcs; |
54 | 54 | |
55 | 55 | struct packet { |
56 | 56 | int length; |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/fsm.c,v
retrieving revision 1.6
diff -u -r1.6 fsm.c
|
|
|
45 | 45 | |
46 | 46 | #define PROTO_NAME(f) ((f)->callbacks->proto_name) |
47 | 47 | |
48 | | int peer_mru[NUM_PPP]; |
| 48 | static int peer_mru[NUM_PPP]; |
49 | 49 | |
50 | 50 | |
51 | 51 | /* |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/lcp.c,v
retrieving revision 1.3
diff -u -r1.3 lcp.c
|
|
|
38 | 38 | /* |
39 | 39 | * LCP-related command-line options. |
40 | 40 | */ |
41 | | int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ |
42 | | int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ |
43 | | bool lax_recv = 0; /* accept control chars in asyncmap */ |
| 41 | static int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ |
| 42 | static int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ |
| 43 | static bool lax_recv = 0; /* accept control chars in asyncmap */ |
44 | 44 | |
45 | 45 | static int setescape __P((char **)); |
46 | 46 | |
… |
… |
|
335 | 335 | { |
336 | 336 | fsm *f = &lcp_fsm[unit]; |
337 | 337 | |
338 | | if (phase != PHASE_DEAD) |
| 338 | if (pppd_phase != PHASE_DEAD) |
339 | 339 | new_phase(PHASE_TERMINATE); |
340 | 340 | if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { |
341 | 341 | /* |
… |
… |
|
1063 | 1063 | if (++try.numloops >= lcp_loopbackfail) { |
1064 | 1064 | notice("Serial line is looped back."); |
1065 | 1065 | lcp_close(f->unit, "Loopback detected"); |
1066 | | status = EXIT_LOOPBACK; |
| 1066 | pppd_status = EXIT_LOOPBACK; |
1067 | 1067 | } |
1068 | 1068 | } else |
1069 | 1069 | try.numloops = 0; |
… |
… |
|
1815 | 1815 | info("No response to %d echo-requests", lcp_echos_pending); |
1816 | 1816 | notice("Serial link appears to be disconnected."); |
1817 | 1817 | lcp_close(f->unit, "Peer not responding"); |
1818 | | status = EXIT_PEER_DEAD; |
| 1818 | pppd_status = EXIT_PEER_DEAD; |
1819 | 1819 | } |
1820 | 1820 | } |
1821 | 1821 | |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/options.c,v
retrieving revision 1.4
diff -u -r1.4 options.c
|
|
|
623 | 623 | |
624 | 624 | if ((opt->flags & OPT_PREPASS) == 0 && prepass) |
625 | 625 | return 1; |
626 | | if ((opt->flags & OPT_INITONLY) && phase != PHASE_INITIALIZE) { |
| 626 | if ((opt->flags & OPT_INITONLY) && pppd_phase != PHASE_INITIALIZE) { |
627 | 627 | option_error("it's too late to use the %s option", opt->name); |
628 | 628 | return 0; |
629 | 629 | } |
… |
… |
|
777 | 777 | static void |
778 | 778 | usage() |
779 | 779 | { |
780 | | if (phase == PHASE_INITIALIZE) |
| 780 | if (pppd_phase == PHASE_INITIALIZE) |
781 | 781 | fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION, |
782 | | progname); |
| 782 | "rtems_pppd"); |
783 | 783 | } |
784 | 784 | |
785 | 785 | /* |
786 | 786 | * option_error - print a message about an error in an option. |
787 | 787 | * The message is logged, and also sent to |
788 | | * stderr if phase == PHASE_INITIALIZE. |
| 788 | * stderr if pppd_phase == PHASE_INITIALIZE. |
789 | 789 | */ |
790 | 790 | void |
791 | 791 | option_error __V((char *fmt, ...)) |
… |
… |
|
1322 | 1322 | return -1; |
1323 | 1323 | } |
1324 | 1324 | |
1325 | | if (phase != PHASE_INITIALIZE) { |
| 1325 | if (pppd_phase != PHASE_INITIALIZE) { |
1326 | 1326 | option_error("device name cannot be changed after initialization"); |
1327 | 1327 | return -1; |
1328 | 1328 | } else if (devnam_fixed) { |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/pppd.h,v
retrieving revision 1.7
diff -u -r1.7 pppd.h
|
|
|
137 | 137 | * Global variables. |
138 | 138 | */ |
139 | 139 | |
140 | | extern int kill_link; /* Signal to terminate processing loop */ |
| 140 | extern int pppd_kill_link; /* Signal to terminate processing loop */ |
141 | 141 | extern int hungup; /* Physical layer has disconnected */ |
142 | 142 | extern int pppifunit; /* Interface unit number */ |
143 | 143 | extern char ifname[]; /* Interface name */ |
144 | 144 | extern int ttyfd; /* Serial device file descriptor */ |
145 | 145 | extern char hostname[]; /* Our hostname */ |
146 | 146 | extern u_char outpacket_buf[]; /* Buffer for outgoing packets */ |
147 | | extern int phase; /* Current state of link - see values below */ |
| 147 | extern int pppd_phase; /* Current state of link - see values below */ |
148 | 148 | extern int baud_rate; /* Current link speed in bits/sec */ |
149 | | extern char *progname; /* Name of this program */ |
150 | 149 | extern int redirect_stderr;/* Connector's stderr should go to file */ |
151 | 150 | extern char peer_authname[];/* Authenticated name of peer */ |
152 | 151 | extern int privileged; /* We were run by real-uid root */ |
… |
… |
|
159 | 158 | extern int using_pty; /* using pty as device (notty or pty opt.) */ |
160 | 159 | extern int log_to_fd; /* logging to this fd as well as syslog */ |
161 | 160 | extern char *no_ppp_msg; /* message to print if ppp not in kernel */ |
162 | | extern volatile int status; /* exit status for pppd */ |
| 161 | extern volatile int pppd_status; /* exit status for pppd */ |
163 | 162 | extern int devnam_fixed; /* can no longer change devnam */ |
164 | 163 | extern int unsuccess; /* # unsuccessful connection attempts */ |
165 | 164 | extern int do_callback; /* set if we want to do callback next */ |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/rtemsmain.c,v
retrieving revision 1.3
diff -u -r1.3 rtemsmain.c
|
|
|
74 | 74 | char ifname[32]; /* Interface name */ |
75 | 75 | int pppifunit; /* Interface unit number */ |
76 | 76 | |
77 | | char *progname; /* Name of this program */ |
78 | 77 | char hostname[MAXNAMELEN]; /* Our hostname */ |
79 | 78 | static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */ |
80 | 79 | |
… |
… |
|
87 | 86 | struct stat devstat; /* result of stat() on devnam */ |
88 | 87 | int prepass = 0; /* doing prepass to find device name */ |
89 | 88 | int devnam_fixed; /* set while in options.ttyxx file */ |
90 | | volatile int status; /* exit status for pppd */ |
| 89 | volatile int pppd_status; /* exit status for pppd */ |
91 | 90 | int unsuccess; /* # unsuccessful connection attempts */ |
92 | 91 | int do_callback; /* != 0 if we should do callback next */ |
93 | 92 | int doing_callback; /* != 0 if we are doing callback */ |
… |
… |
|
102 | 101 | static int pty_slave; /* fd for slave side of pty */ |
103 | 102 | static int real_ttyfd; /* fd for actual serial port (not pty) */ |
104 | 103 | |
105 | | int phase; /* where the link is at */ |
106 | | int kill_link; |
| 104 | int pppd_phase; /* where the link is at */ |
| 105 | int pppd_kill_link; |
107 | 106 | int open_ccp_flag; |
108 | 107 | |
109 | 108 | char **script_env; /* Env. variable values for scripts */ |
… |
… |
|
195 | 194 | (*protp->init)(0); |
196 | 195 | #endif |
197 | 196 | |
198 | | progname = *argv; |
199 | | |
200 | 197 | |
201 | 198 | if (!ppp_available()) { |
202 | 199 | option_error(no_ppp_msg); |
… |
… |
|
237 | 234 | need_holdoff = 1; |
238 | 235 | ttyfd = -1; |
239 | 236 | real_ttyfd = -1; |
240 | | status = EXIT_OK; |
| 237 | pppd_status = EXIT_OK; |
241 | 238 | ++unsuccess; |
242 | 239 | doing_callback = do_callback; |
243 | 240 | do_callback = 0; |
… |
… |
|
260 | 257 | * in order to wait for the carrier detect signal from the modem. |
261 | 258 | */ |
262 | 259 | hungup = 0; |
263 | | kill_link = 0; |
| 260 | pppd_kill_link = 0; |
264 | 261 | connector = doing_callback? callback_script: connect_script; |
265 | 262 | if (devnam[0] != 0) { |
266 | 263 | for (;;) { |
… |
… |
|
275 | 272 | errno = err; |
276 | 273 | if (err != EINTR) { |
277 | 274 | error("Failed to open %s: %m", devnam); |
278 | | status = EXIT_OPEN_FAILED; |
| 275 | pppd_status = EXIT_OPEN_FAILED; |
279 | 276 | } |
280 | 277 | if (!persist || err != EINTR) |
281 | 278 | goto fail; |
… |
… |
|
313 | 310 | if (initializer && initializer[0]) { |
314 | 311 | if (device_script(ttyfd, DIALER_INIT, initializer) < 0) { |
315 | 312 | error("Initializer script failed"); |
316 | | status = EXIT_INIT_FAILED; |
| 313 | pppd_status = EXIT_INIT_FAILED; |
317 | 314 | goto fail; |
318 | 315 | } |
319 | | if (kill_link) |
| 316 | if (pppd_kill_link) |
320 | 317 | goto disconnect; |
321 | 318 | |
322 | 319 | info("Serial port initialized."); |
… |
… |
|
325 | 322 | if (connector && connector[0]) { |
326 | 323 | if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) { |
327 | 324 | error("Connect script failed"); |
328 | | status = EXIT_CONNECT_FAILED; |
| 325 | pppd_status = EXIT_CONNECT_FAILED; |
329 | 326 | goto fail; |
330 | 327 | } |
331 | | if (kill_link) |
| 328 | if (pppd_kill_link) |
332 | 329 | goto disconnect; |
333 | 330 | |
334 | 331 | info("Serial connection established."); |
… |
… |
|
350 | 347 | break; |
351 | 348 | if (errno != EINTR) { |
352 | 349 | error("Failed to reopen %s: %m", devnam); |
353 | | status = EXIT_OPEN_FAILED; |
| 350 | pppd_status = EXIT_OPEN_FAILED; |
354 | 351 | } |
355 | | if (!persist || errno != EINTR || hungup || kill_link) |
| 352 | if (!persist || errno != EINTR || hungup || pppd_kill_link) |
356 | 353 | goto fail; |
357 | 354 | } |
358 | 355 | close(i); |
… |
… |
|
370 | 367 | /* set up the serial device as a ppp interface */ |
371 | 368 | fd_ppp = establish_ppp(ttyfd); |
372 | 369 | if (fd_ppp < 0) { |
373 | | status = EXIT_FATAL_ERROR; |
| 370 | pppd_status = EXIT_FATAL_ERROR; |
374 | 371 | goto disconnect; |
375 | 372 | } |
376 | 373 | |
… |
… |
|
390 | 387 | lcp_open(0); /* Start protocol */ |
391 | 388 | |
392 | 389 | open_ccp_flag = 0; |
393 | | status = EXIT_NEGOTIATION_FAILED; |
| 390 | pppd_status = EXIT_NEGOTIATION_FAILED; |
394 | 391 | new_phase(PHASE_ESTABLISH); |
395 | | while (phase != PHASE_DEAD) { |
| 392 | while (pppd_phase != PHASE_DEAD) { |
396 | 393 | wait_input(timeleft(&timo)); |
397 | 394 | calltimeout(); |
398 | 395 | get_input(); |
399 | 396 | |
400 | | if (kill_link) { |
| 397 | if (pppd_kill_link) { |
401 | 398 | lcp_close(0, "User request"); |
402 | | kill_link = 0; |
| 399 | pppd_kill_link = 0; |
403 | 400 | } |
404 | 401 | if (open_ccp_flag) { |
405 | | if (phase == PHASE_NETWORK || phase == PHASE_RUNNING) { |
| 402 | if (pppd_phase == PHASE_NETWORK || pppd_phase == PHASE_RUNNING) { |
406 | 403 | ccp_fsm[0].flags = OPT_RESTART; /* clears OPT_SILENT */ |
407 | 404 | (*ccp_protent.open)(0); |
408 | 405 | } |
… |
… |
|
450 | 447 | if (!persist || (maxfail > 0 && unsuccess >= maxfail)) |
451 | 448 | break; |
452 | 449 | |
453 | | kill_link = 0; |
| 450 | pppd_kill_link = 0; |
454 | 451 | if (demand) |
455 | 452 | demand_discard(); |
456 | 453 | t = need_holdoff? holdoff: 0; |
… |
… |
|
463 | 460 | wait_input(timeleft(&timo)); |
464 | 461 | |
465 | 462 | calltimeout(); |
466 | | if (kill_link) { |
467 | | kill_link = 0; |
| 463 | if (pppd_kill_link) { |
| 464 | pppd_kill_link = 0; |
468 | 465 | new_phase(PHASE_DORMANT); /* allow signal to end holdoff */ |
469 | 466 | } |
470 | | } while (phase == PHASE_HOLDOFF); |
| 467 | } while (pppd_phase == PHASE_HOLDOFF); |
471 | 468 | if (!persist) |
472 | 469 | break; |
473 | 470 | } |
474 | 471 | } |
475 | 472 | |
476 | | die(status); |
477 | | return status; |
| 473 | die(pppd_status); |
| 474 | return pppd_status; |
478 | 475 | } |
479 | 476 | |
480 | 477 | /* |
… |
… |
|
591 | 588 | if (len == 0) { |
592 | 589 | notice("Modem hangup"); |
593 | 590 | hungup = 1; |
594 | | status = EXIT_HANGUP; |
| 591 | pppd_status = EXIT_HANGUP; |
595 | 592 | lcp_lowerdown(0); /* serial link is no longer available */ |
596 | 593 | link_terminated(0); |
597 | 594 | return; |
… |
… |
|
621 | 618 | * Until we get past the authentication phase, toss all packets |
622 | 619 | * except LCP, LQR and authentication packets. |
623 | 620 | */ |
624 | | if (phase <= PHASE_AUTHENTICATE |
| 621 | if (pppd_phase <= PHASE_AUTHENTICATE |
625 | 622 | && !(protocol == PPP_LCP || protocol == PPP_LQR |
626 | 623 | || protocol == PPP_PAP || protocol == PPP_CHAP)) { |
627 | 624 | MAINDEBUG(("get_input: discarding proto 0x%x in phase %d", |
628 | | protocol, phase)); |
| 625 | protocol, pppd_phase)); |
629 | 626 | return; |
630 | 627 | } |
631 | 628 | |
… |
… |
|
663 | 660 | new_phase(p) |
664 | 661 | int p; |
665 | 662 | { |
666 | | phase = p; |
| 663 | pppd_phase = p; |
667 | 664 | if (new_phase_hook) |
668 | 665 | (*new_phase_hook)(p); |
669 | 666 | } |
RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/rtemspppd.c,v
retrieving revision 1.3
diff -u -r1.3 rtemspppd.c
|
|
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /* save current phase value */ |
180 | | prevPhase = phase; |
181 | | phase = PHASE_INITIALIZE; |
| 180 | prevPhase = pppd_phase; |
| 181 | pppd_phase = PHASE_INITIALIZE; |
182 | 182 | |
183 | 183 | /* process option and reset phase value */ |
184 | 184 | iReturn = options_from_list(&option, 1); |
185 | | phase = prevPhase; |
| 185 | pppd_phase = prevPhase; |
186 | 186 | } |
187 | 187 | |
188 | 188 | return ( iReturn ); |
… |
… |
|
200 | 200 | { |
201 | 201 | /* set pppd global variables to disconnect */ |
202 | 202 | persist = 0; |
203 | | kill_link = 1; |
| 203 | pppd_kill_link = 1; |
204 | 204 | } |
205 | 205 | |
206 | 206 | int rtems_pppd_disconnect(void) |