* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define RCSID "$Id: main.c,v 1.124 2003/03/04 05:37:22 fcusack Exp $"
+#define RCSID "$Id: main.c,v 1.126 2003/04/07 00:01:45 paulus Exp $"
#include <stdio.h>
#include <ctype.h>
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.
/* 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]);
}
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);
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);
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.
*/
if (pid > 0) {
close(pipefd[1]);
/* this read() blocks until the close(pipefd[1]) below */
- while (read(pipefd[0], buf, 1) < 0)
- if (errno != EINTR)
- break;
+ complete_read(pipefd[0], buf, 1);
close(pipefd[0]);
return pid;
}