From 48cdb95aa2444a386a911be1a8251483d79a9935 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 10 Apr 2003 16:20:38 +0000 Subject: 2003-04-10 Joel Sherrill PR 371/pppd * pppd/auth.c, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/lcp.c, pppd/options.c, pppd/pppd.h, pppd/rtemsmain.c, pppd/rtemspppd.c: Change many symbols to static. There are still global symbols in rtemspppd.h which might need to be changed or converted into member of a structure which is dereferenced with a pointer that is managed as a per task variable. But this patch should avoid many conflicts. --- c/src/libnetworking/ChangeLog | 10 ++++++ c/src/libnetworking/pppd/auth.c | 16 +++++----- c/src/libnetworking/pppd/chat.c | 17 ++++------- c/src/libnetworking/pppd/demand.c | 12 ++++---- c/src/libnetworking/pppd/fsm.c | 2 +- c/src/libnetworking/pppd/lcp.c | 12 ++++---- c/src/libnetworking/pppd/options.c | 10 +++--- c/src/libnetworking/pppd/pppd.h | 7 ++--- c/src/libnetworking/pppd/rtemsmain.c | 59 +++++++++++++++++------------------- c/src/libnetworking/pppd/rtemspppd.c | 8 ++--- 10 files changed, 77 insertions(+), 76 deletions(-) (limited to 'c/src/libnetworking') diff --git a/c/src/libnetworking/ChangeLog b/c/src/libnetworking/ChangeLog index dbb17fcbd9..1b2de939f2 100644 --- a/c/src/libnetworking/ChangeLog +++ b/c/src/libnetworking/ChangeLog @@ -1,3 +1,13 @@ +2003-04-10 Joel Sherrill + + PR 371/pppd + * pppd/auth.c, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/lcp.c, + pppd/options.c, pppd/pppd.h, pppd/rtemsmain.c, pppd/rtemspppd.c: + Change many symbols to static. There are still global symbols in + rtemspppd.h which might need to be changed or converted into member + of a structure which is dereferenced with a pointer that is managed + as a per task variable. But this patch should avoid many conflicts. + 2003-03-18 Ralf Corsepius * pppd/utils.c: Remove strlcpy, strlcat. diff --git a/c/src/libnetworking/pppd/auth.c b/c/src/libnetworking/pppd/auth.c index 418ad7d58e..a92654a650 100644 --- a/c/src/libnetworking/pppd/auth.c +++ b/c/src/libnetworking/pppd/auth.c @@ -249,7 +249,7 @@ void link_terminated(unit) int unit; { - if (phase == PHASE_DEAD) + if (pppd_phase == PHASE_DEAD) return; if (pap_logout_hook) { pap_logout_hook(); @@ -283,7 +283,7 @@ link_down(unit) } num_np_open = 0; num_np_up = 0; - if (phase != PHASE_DEAD) + if (pppd_phase != PHASE_DEAD) new_phase(PHASE_TERMINATE); } @@ -323,7 +323,7 @@ link_established(unit) } else if (!wo->neg_upap || !null_login(unit)) { warn("peer refused to authenticate: terminating link"); lcp_close(unit, "peer refused to authenticate"); - status = EXIT_PEER_AUTH_FAILED; + pppd_status = EXIT_PEER_AUTH_FAILED; return; } } @@ -425,7 +425,7 @@ auth_peer_fail(unit, protocol) * Authentication failure: take the link down */ lcp_close(unit, "Authentication failed"); - status = EXIT_PEER_AUTH_FAILED; + pppd_status = EXIT_PEER_AUTH_FAILED; } /* @@ -483,7 +483,7 @@ auth_withpeer_fail(unit, protocol) * authentication secrets. */ lcp_close(unit, "Failed to authenticate ourselves to peer"); - status = EXIT_AUTH_TOPEER_FAILED; + pppd_status = EXIT_AUTH_TOPEER_FAILED; } /* @@ -531,7 +531,7 @@ np_up(unit, proto) /* * At this point we consider that the link has come up successfully. */ - status = EXIT_OK; + pppd_status = EXIT_OK; unsuccess = 0; new_phase(PHASE_RUNNING); @@ -603,7 +603,7 @@ check_idle(arg) notice("Terminating connection due to lack of activity."); lcp_close(0, "Link inactive"); need_holdoff = 0; - status = EXIT_IDLE_TIMEOUT; + pppd_status = EXIT_IDLE_TIMEOUT; } else { TIMEOUT(check_idle, NULL, tlim); } @@ -618,7 +618,7 @@ connect_time_expired(arg) { info("Connect time expired"); lcp_close(0, "Connect time expired"); /* Close connection */ - status = EXIT_CONNECT_TIME; + pppd_status = EXIT_CONNECT_TIME; } /* diff --git a/c/src/libnetworking/pppd/chat.c b/c/src/libnetworking/pppd/chat.c index 74be1b06f0..d40e3b2e46 100644 --- a/c/src/libnetworking/pppd/chat.c +++ b/c/src/libnetworking/pppd/chat.c @@ -140,22 +140,17 @@ static int _O = 0; /* Internal state */ #endif /*************** Micro getopt() *********************************************/ -char *program_name; - #define MAX_ABORTS 16 #define MAX_REPORTS 16 #define DEFAULT_CHAT_TIMEOUT 45 #define MAX_TIMEOUTS 10 -int echo = 0; -int quiet = 0; -int report = 0; -int use_env = 0; -int exit_code = 0; -char *report_file = (char *) 0; -char *chat_file = (char *) 0; -char *phone_num = (char *) 0; -char *phone_num2 = (char *) 0; +static int echo = 0; +static int quiet = 0; +static int use_env = 0; +static int exit_code = 0; +static char *phone_num = (char *) 0; +static char *phone_num2 = (char *) 0; static int ttyfd; static int timeout = DEFAULT_CHAT_TIMEOUT; diff --git a/c/src/libnetworking/pppd/demand.c b/c/src/libnetworking/pppd/demand.c index 1f2e9932d4..0b807575c2 100644 --- a/c/src/libnetworking/pppd/demand.c +++ b/c/src/libnetworking/pppd/demand.c @@ -45,12 +45,12 @@ static const char rcsid[] = RCSID; -char *frame; -int framelen; -int framemax; -int escape_flag; -int flush_flag; -int fcs; +static char *frame; +static int framelen; +static int framemax; +static int escape_flag; +static int flush_flag; +static int fcs; struct packet { int length; diff --git a/c/src/libnetworking/pppd/fsm.c b/c/src/libnetworking/pppd/fsm.c index 53401a9129..7248bc4807 100644 --- a/c/src/libnetworking/pppd/fsm.c +++ b/c/src/libnetworking/pppd/fsm.c @@ -45,7 +45,7 @@ static void fsm_sconfreq __P((fsm *, int)); #define PROTO_NAME(f) ((f)->callbacks->proto_name) -int peer_mru[NUM_PPP]; +static int peer_mru[NUM_PPP]; /* diff --git a/c/src/libnetworking/pppd/lcp.c b/c/src/libnetworking/pppd/lcp.c index 781f5569ad..4308c86026 100644 --- a/c/src/libnetworking/pppd/lcp.c +++ b/c/src/libnetworking/pppd/lcp.c @@ -38,9 +38,9 @@ static const char rcsid[] = RCSID; /* * LCP-related command-line options. */ -int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ -int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ -bool lax_recv = 0; /* accept control chars in asyncmap */ +static int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ +static int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ +static bool lax_recv = 0; /* accept control chars in asyncmap */ static int setescape __P((char **)); @@ -335,7 +335,7 @@ lcp_close(unit, reason) { fsm *f = &lcp_fsm[unit]; - if (phase != PHASE_DEAD) + if (pppd_phase != PHASE_DEAD) new_phase(PHASE_TERMINATE); if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { /* @@ -1063,7 +1063,7 @@ lcp_nakci(f, p, len) if (++try.numloops >= lcp_loopbackfail) { notice("Serial line is looped back."); lcp_close(f->unit, "Loopback detected"); - status = EXIT_LOOPBACK; + pppd_status = EXIT_LOOPBACK; } } else try.numloops = 0; @@ -1815,7 +1815,7 @@ void LcpLinkFailure (f) info("No response to %d echo-requests", lcp_echos_pending); notice("Serial link appears to be disconnected."); lcp_close(f->unit, "Peer not responding"); - status = EXIT_PEER_DEAD; + pppd_status = EXIT_PEER_DEAD; } } diff --git a/c/src/libnetworking/pppd/options.c b/c/src/libnetworking/pppd/options.c index 00dcf591ba..fb686d94a6 100644 --- a/c/src/libnetworking/pppd/options.c +++ b/c/src/libnetworking/pppd/options.c @@ -623,7 +623,7 @@ process_option(opt, argv) if ((opt->flags & OPT_PREPASS) == 0 && prepass) return 1; - if ((opt->flags & OPT_INITONLY) && phase != PHASE_INITIALIZE) { + if ((opt->flags & OPT_INITONLY) && pppd_phase != PHASE_INITIALIZE) { option_error("it's too late to use the %s option", opt->name); return 0; } @@ -777,15 +777,15 @@ add_options(opt) static void usage() { - if (phase == PHASE_INITIALIZE) + if (pppd_phase == PHASE_INITIALIZE) fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION, - progname); + "rtems_pppd"); } /* * option_error - print a message about an error in an option. * The message is logged, and also sent to - * stderr if phase == PHASE_INITIALIZE. + * stderr if pppd_phase == PHASE_INITIALIZE. */ void option_error __V((char *fmt, ...)) @@ -1322,7 +1322,7 @@ setdevname(cp) return -1; } - if (phase != PHASE_INITIALIZE) { + if (pppd_phase != PHASE_INITIALIZE) { option_error("device name cannot be changed after initialization"); return -1; } else if (devnam_fixed) { diff --git a/c/src/libnetworking/pppd/pppd.h b/c/src/libnetworking/pppd/pppd.h index 6af6ec1fd6..0ecd2e1d23 100644 --- a/c/src/libnetworking/pppd/pppd.h +++ b/c/src/libnetworking/pppd/pppd.h @@ -137,16 +137,15 @@ struct wordlist { * Global variables. */ -extern int kill_link; /* Signal to terminate processing loop */ +extern int pppd_kill_link; /* Signal to terminate processing loop */ extern int hungup; /* Physical layer has disconnected */ extern int pppifunit; /* Interface unit number */ extern char ifname[]; /* Interface name */ extern int ttyfd; /* Serial device file descriptor */ extern char hostname[]; /* Our hostname */ extern u_char outpacket_buf[]; /* Buffer for outgoing packets */ -extern int phase; /* Current state of link - see values below */ +extern int pppd_phase; /* Current state of link - see values below */ extern int baud_rate; /* Current link speed in bits/sec */ -extern char *progname; /* Name of this program */ extern int redirect_stderr;/* Connector's stderr should go to file */ extern char peer_authname[];/* Authenticated name of peer */ extern int privileged; /* We were run by real-uid root */ @@ -159,7 +158,7 @@ extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */ extern int using_pty; /* using pty as device (notty or pty opt.) */ extern int log_to_fd; /* logging to this fd as well as syslog */ extern char *no_ppp_msg; /* message to print if ppp not in kernel */ -extern volatile int status; /* exit status for pppd */ +extern volatile int pppd_status; /* exit status for pppd */ extern int devnam_fixed; /* can no longer change devnam */ extern int unsuccess; /* # unsuccessful connection attempts */ extern int do_callback; /* set if we want to do callback next */ diff --git a/c/src/libnetworking/pppd/rtemsmain.c b/c/src/libnetworking/pppd/rtemsmain.c index 17804db38f..2c0832b94f 100644 --- a/c/src/libnetworking/pppd/rtemsmain.c +++ b/c/src/libnetworking/pppd/rtemsmain.c @@ -74,7 +74,6 @@ static const char rcsid[] = RCSID; char ifname[32]; /* Interface name */ int pppifunit; /* Interface unit number */ -char *progname; /* Name of this program */ char hostname[MAXNAMELEN]; /* Our hostname */ static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */ @@ -87,7 +86,7 @@ int detached; /* have detached from terminal */ struct stat devstat; /* result of stat() on devnam */ int prepass = 0; /* doing prepass to find device name */ int devnam_fixed; /* set while in options.ttyxx file */ -volatile int status; /* exit status for pppd */ +volatile int pppd_status; /* exit status for pppd */ int unsuccess; /* # unsuccessful connection attempts */ int do_callback; /* != 0 if we should do callback next */ int doing_callback; /* != 0 if we are doing callback */ @@ -102,8 +101,8 @@ static int pty_master; /* fd for master side of pty */ static int pty_slave; /* fd for slave side of pty */ static int real_ttyfd; /* fd for actual serial port (not pty) */ -int phase; /* where the link is at */ -int kill_link; +int pppd_phase; /* where the link is at */ +int pppd_kill_link; int open_ccp_flag; char **script_env; /* Env. variable values for scripts */ @@ -195,8 +194,6 @@ pppdmain(argc, argv) (*protp->init)(0); #endif - progname = *argv; - if (!ppp_available()) { option_error(no_ppp_msg); @@ -237,7 +234,7 @@ pppdmain(argc, argv) need_holdoff = 1; ttyfd = -1; real_ttyfd = -1; - status = EXIT_OK; + pppd_status = EXIT_OK; ++unsuccess; doing_callback = do_callback; do_callback = 0; @@ -260,7 +257,7 @@ pppdmain(argc, argv) * in order to wait for the carrier detect signal from the modem. */ hungup = 0; - kill_link = 0; + pppd_kill_link = 0; connector = doing_callback? callback_script: connect_script; if (devnam[0] != 0) { for (;;) { @@ -275,7 +272,7 @@ pppdmain(argc, argv) errno = err; if (err != EINTR) { error("Failed to open %s: %m", devnam); - status = EXIT_OPEN_FAILED; + pppd_status = EXIT_OPEN_FAILED; } if (!persist || err != EINTR) goto fail; @@ -313,10 +310,10 @@ pppdmain(argc, argv) if (initializer && initializer[0]) { if (device_script(ttyfd, DIALER_INIT, initializer) < 0) { error("Initializer script failed"); - status = EXIT_INIT_FAILED; + pppd_status = EXIT_INIT_FAILED; goto fail; } - if (kill_link) + if (pppd_kill_link) goto disconnect; info("Serial port initialized."); @@ -325,10 +322,10 @@ pppdmain(argc, argv) if (connector && connector[0]) { if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) { error("Connect script failed"); - status = EXIT_CONNECT_FAILED; + pppd_status = EXIT_CONNECT_FAILED; goto fail; } - if (kill_link) + if (pppd_kill_link) goto disconnect; info("Serial connection established."); @@ -350,9 +347,9 @@ pppdmain(argc, argv) break; if (errno != EINTR) { error("Failed to reopen %s: %m", devnam); - status = EXIT_OPEN_FAILED; + pppd_status = EXIT_OPEN_FAILED; } - if (!persist || errno != EINTR || hungup || kill_link) + if (!persist || errno != EINTR || hungup || pppd_kill_link) goto fail; } close(i); @@ -370,7 +367,7 @@ pppdmain(argc, argv) /* set up the serial device as a ppp interface */ fd_ppp = establish_ppp(ttyfd); if (fd_ppp < 0) { - status = EXIT_FATAL_ERROR; + pppd_status = EXIT_FATAL_ERROR; goto disconnect; } @@ -390,19 +387,19 @@ pppdmain(argc, argv) lcp_open(0); /* Start protocol */ open_ccp_flag = 0; - status = EXIT_NEGOTIATION_FAILED; + pppd_status = EXIT_NEGOTIATION_FAILED; new_phase(PHASE_ESTABLISH); - while (phase != PHASE_DEAD) { + while (pppd_phase != PHASE_DEAD) { wait_input(timeleft(&timo)); calltimeout(); get_input(); - if (kill_link) { + if (pppd_kill_link) { lcp_close(0, "User request"); - kill_link = 0; + pppd_kill_link = 0; } if (open_ccp_flag) { - if (phase == PHASE_NETWORK || phase == PHASE_RUNNING) { + if (pppd_phase == PHASE_NETWORK || pppd_phase == PHASE_RUNNING) { ccp_fsm[0].flags = OPT_RESTART; /* clears OPT_SILENT */ (*ccp_protent.open)(0); } @@ -450,7 +447,7 @@ pppdmain(argc, argv) if (!persist || (maxfail > 0 && unsuccess >= maxfail)) break; - kill_link = 0; + pppd_kill_link = 0; if (demand) demand_discard(); t = need_holdoff? holdoff: 0; @@ -463,18 +460,18 @@ pppdmain(argc, argv) wait_input(timeleft(&timo)); calltimeout(); - if (kill_link) { - kill_link = 0; + if (pppd_kill_link) { + pppd_kill_link = 0; new_phase(PHASE_DORMANT); /* allow signal to end holdoff */ } - } while (phase == PHASE_HOLDOFF); + } while (pppd_phase == PHASE_HOLDOFF); if (!persist) break; } } - die(status); - return status; + die(pppd_status); + return pppd_status; } /* @@ -591,7 +588,7 @@ get_input(void) if (len == 0) { notice("Modem hangup"); hungup = 1; - status = EXIT_HANGUP; + pppd_status = EXIT_HANGUP; lcp_lowerdown(0); /* serial link is no longer available */ link_terminated(0); return; @@ -621,11 +618,11 @@ get_input(void) * Until we get past the authentication phase, toss all packets * except LCP, LQR and authentication packets. */ - if (phase <= PHASE_AUTHENTICATE + if (pppd_phase <= PHASE_AUTHENTICATE && !(protocol == PPP_LCP || protocol == PPP_LQR || protocol == PPP_PAP || protocol == PPP_CHAP)) { MAINDEBUG(("get_input: discarding proto 0x%x in phase %d", - protocol, phase)); + protocol, pppd_phase)); return; } @@ -663,7 +660,7 @@ void new_phase(p) int p; { - phase = p; + pppd_phase = p; if (new_phase_hook) (*new_phase_hook)(p); } diff --git a/c/src/libnetworking/pppd/rtemspppd.c b/c/src/libnetworking/pppd/rtemspppd.c index 1277499205..ac8055fc58 100644 --- a/c/src/libnetworking/pppd/rtemspppd.c +++ b/c/src/libnetworking/pppd/rtemspppd.c @@ -177,12 +177,12 @@ int rtems_pppd_set_option(const char *pOption, const char *pValue) } /* save current phase value */ - prevPhase = phase; - phase = PHASE_INITIALIZE; + prevPhase = pppd_phase; + pppd_phase = PHASE_INITIALIZE; /* process option and reset phase value */ iReturn = options_from_list(&option, 1); - phase = prevPhase; + pppd_phase = prevPhase; } return ( iReturn ); @@ -200,7 +200,7 @@ static void timeout_terminate(void *arg) { /* set pppd global variables to disconnect */ persist = 0; - kill_link = 1; + pppd_kill_link = 1; } int rtems_pppd_disconnect(void) -- cgit v1.2.3