X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmain.c;h=8511503f78aa8296ac839df7728bb161542d82c7;hb=a0af5342ed838a6bbc6407def5eee2889435a57a;hp=a01b852cc26c1dad05dabd37dcdecb5694694aa3;hpb=cb67581446e926290c6147634f7f467f48c806b5;p=ppp.git diff --git a/pppd/main.c b/pppd/main.c index a01b852..8511503 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -40,7 +40,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: main.c,v 1.123 2003/03/03 05:11:46 paulus Exp $" +#define RCSID "$Id: main.c,v 1.127 2003/05/12 07:31:36 fcusack Exp $" #include #include @@ -175,6 +175,8 @@ struct pppd_stats link_stats; unsigned link_connect_time; int link_stats_valid; +int error_count; + /* * We maintain a list of child process pids and * functions to call when they exit. @@ -436,8 +438,6 @@ main(argc, argv) waiting = 0; - create_linkpidfile(getpid()); - /* * If we're doing dial-on-demand, set up the interface now. */ @@ -457,6 +457,7 @@ main(argc, argv) * Configure the interface and mark it up, etc. */ demand_conf(); + create_linkpidfile(getpid()); } do_callback = 0; @@ -513,6 +514,9 @@ main(argc, argv) status = EXIT_FATAL_ERROR; goto disconnect; } + /* create the pid file, now that we've obtained a ppp interface */ + if (!demand) + create_linkpidfile(getpid()); if (!demand && ifunit >= 0) set_ifunit(1); @@ -822,7 +826,7 @@ detach() /* wait for parent to finish updating pid & lock files and die */ close(pipefd[1]); - read(pipefd[0], numbuf, 1); + complete_read(pipefd[0], numbuf, 1); close(pipefd[0]); } @@ -852,7 +856,7 @@ create_pidfile(pid) slprintf(pidfilename, sizeof(pidfilename), "%s%s.pid", _PATH_VARRUN, ifname); if ((pidfile = fopen(pidfilename, "w")) != NULL) { - fprintf(pidfile, "%d\n", getpid()); + fprintf(pidfile, "%d\n", pid); (void) fclose(pidfile); } else { error("Failed to create pid file %s: %m", pidfilename); @@ -872,7 +876,7 @@ create_linkpidfile(pid) slprintf(linkpidfile, sizeof(linkpidfile), "%sppp-%s.pid", _PATH_VARRUN, linkname); if ((pidfile = fopen(linkpidfile, "w")) != NULL) { - fprintf(pidfile, "%d\n", getpid()); + fprintf(pidfile, "%d\n", pid); if (ifname[0]) fprintf(pidfile, "%s\n", ifname); (void) fclose(pidfile); @@ -1060,6 +1064,48 @@ get_input() lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN); } +/* + * ppp_send_config - configure the transmit-side characteristics of + * the ppp interface. Returns -1, indicating an error, if the channel + * send_config procedure called error() (or incremented error_count + * itself), otherwise 0. + */ +int +ppp_send_config(unit, mtu, accm, pcomp, accomp) + int unit, mtu; + u_int32_t accm; + int pcomp, accomp; +{ + int errs; + + if (the_channel->send_config == NULL) + return 0; + errs = error_count; + (*the_channel->send_config)(mtu, accm, pcomp, accomp); + return (error_count != errs)? -1: 0; +} + +/* + * ppp_recv_config - configure the receive-side characteristics of + * the ppp interface. Returns -1, indicating an error, if the channel + * recv_config procedure called error() (or incremented error_count + * itself), otherwise 0. + */ +int +ppp_recv_config(unit, mru, accm, pcomp, accomp) + int unit, mru; + u_int32_t accm; + int pcomp, accomp; +{ + int errs; + + if (the_channel->recv_config == NULL) + return 0; + errs = error_count; + (*the_channel->recv_config)(mru, accm, pcomp, accomp); + return (error_count != errs)? -1: 0; +} + /* * new_phase - signal the start of a new phase of pppd's operation. */ @@ -1428,7 +1474,7 @@ safe_fork() if (pid > 0) { close(pipefd[1]); /* this read() blocks until the close(pipefd[1]) below */ - read(pipefd[0], buf, 1); + complete_read(pipefd[0], buf, 1); close(pipefd[0]); return pid; }