summaryrefslogtreecommitdiff
path: root/pppd
diff options
context:
space:
mode:
Diffstat (limited to 'pppd')
-rw-r--r--pppd/demand.c5
-rw-r--r--pppd/ipcp.c4
-rw-r--r--pppd/main.c32
-rw-r--r--pppd/options.c3
-rw-r--r--pppd/pppd.h8
-rw-r--r--pppd/sys-NeXT.c28
-rw-r--r--pppd/sys-aix4.c8
-rw-r--r--pppd/sys-bsd.c28
-rw-r--r--pppd/sys-linux.c23
-rw-r--r--pppd/sys-osf.c23
-rw-r--r--pppd/sys-sunos4.c57
-rw-r--r--pppd/sys-svr4.c23
-rw-r--r--pppd/sys-ultrix.c28
13 files changed, 240 insertions, 30 deletions
diff --git a/pppd/demand.c b/pppd/demand.c
index 86c176e..cfae882 100644
--- a/pppd/demand.c
+++ b/pppd/demand.c
@@ -18,7 +18,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: demand.c,v 1.9 1999/03/19 01:21:28 paulus Exp $";
+static char rcsid[] = "$Id: demand.c,v 1.10 1999/03/19 04:23:38 paulus Exp $";
#endif
#include <stdio.h>
@@ -62,7 +62,6 @@ struct packet *pend_q;
struct packet *pend_qtail;
static int active_packet __P((unsigned char *, int));
-static int loop_frame __P((unsigned char *, int));
/*
* demand_conf - configure the interface for doing dial-on-demand.
@@ -255,7 +254,7 @@ loop_chars(p, n)
* We apply the active_filter to see if we want this packet to
* bring up the link.
*/
-static int
+int
loop_frame(frame, len)
unsigned char *frame;
int len;
diff --git a/pppd/ipcp.c b/pppd/ipcp.c
index 6e0346b..41eabd2 100644
--- a/pppd/ipcp.c
+++ b/pppd/ipcp.c
@@ -18,7 +18,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: ipcp.c,v 1.42 1999/03/19 01:19:31 paulus Exp $";
+static char rcsid[] = "$Id: ipcp.c,v 1.43 1999/03/19 04:23:39 paulus Exp $";
#endif
/*
@@ -1520,6 +1520,8 @@ ipcp_down(f)
fsm *f;
{
IPCPDEBUG(("ipcp: down"));
+ if (get_ppp_stats(f->unit, &link_stats))
+ link_stats_valid = 1;
if (ipcp_is_up) {
ipcp_is_up = 0;
np_down(f->unit, PPP_IP);
diff --git a/pppd/main.c b/pppd/main.c
index 555ef95..7ad8d3f 100644
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -18,7 +18,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.62 1999/03/19 01:26:41 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.63 1999/03/19 04:23:40 paulus Exp $";
#endif
#include <stdio.h>
@@ -115,6 +115,11 @@ char *no_ppp_msg = "Sorry - this system lacks PPP kernel support\n";
GIDSET_TYPE groups[NGROUPS_MAX];/* groups the user is in */
int ngroups; /* How many groups valid in groups */
+static struct timeval start_time; /* Time when link was started. */
+
+struct ppp_stats link_stats;
+int link_stats_valid;
+
/* Prototypes for procedures local to this file. */
static void create_pidfile __P((void));
@@ -190,6 +195,7 @@ main(argc, argv)
struct protent *protp;
struct stat statbuf;
char numbuf[16];
+ struct timeval now;
phase = PHASE_INITIALIZE;
p = ttyname(0);
@@ -562,6 +568,7 @@ main(argc, argv)
* incoming events (reply, timeout, etc.).
*/
notice("Connect: %s <--> %s", ifname, devnam);
+ gettimeofday(&start_time, NULL);
lcp_lowerup(0);
lcp_open(0); /* Start protocol */
open_ccp_flag = 0;
@@ -595,6 +602,19 @@ main(argc, argv)
}
/*
+ * Print connect time and statistics.
+ */
+ if (gettimeofday(&now, NULL) >= 0) {
+ int t = now.tv_sec - start_time.tv_sec;
+ t = (t + 5) / 6; /* now in 1/10ths of minutes */
+ info("Connect time %d.%d minutes", t/10, t%10);
+ }
+ if (link_stats_valid) {
+ info("Send %d bytes, received %d bytes",
+ link_stats.p.ppp_obytes, link_stats.p.ppp_ibytes);
+ }
+
+ /*
* If we may want to bring the link up again, transfer
* the ppp unit back to the loopback. Set the
* real serial device back to its normal mode of operation.
@@ -1883,7 +1903,10 @@ script_unsetenv(var)
* always leaves destination null-terminated (for len > 0).
*/
size_t
-strlcpy(char *dest, const char *src, size_t len)
+strlcpy(dest, src, len)
+ char *dest;
+ const char *src;
+ size_t len;
{
size_t ret = strlen(src);
@@ -1903,7 +1926,10 @@ strlcpy(char *dest, const char *src, size_t len)
* always leaves destination null-terminated (for len > 0).
*/
size_t
-strlcat(char *dest, const char *src, size_t len)
+strlcat(dest, src, len)
+ char *dest;
+ const char *src;
+ size_t len;
{
size_t dlen = strlen(dest);
diff --git a/pppd/options.c b/pppd/options.c
index c502f5b..53456cc 100644
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -18,14 +18,13 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.52 1999/03/19 01:27:43 paulus Exp $";
+static char rcsid[] = "$Id: options.c,v 1.53 1999/03/19 04:23:44 paulus Exp $";
#endif
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#include <limits.h>
#include <stdlib.h>
#include <termios.h>
#include <syslog.h>
diff --git a/pppd/pppd.h b/pppd/pppd.h
index a01a52b..60ef281 100644
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pppd.h,v 1.32 1999/03/19 01:28:27 paulus Exp $
+ * $Id: pppd.h,v 1.33 1999/03/19 04:23:45 paulus Exp $
*/
/*
@@ -27,6 +27,7 @@
#define __PPPD_H__
#include <stdio.h> /* for FILE */
+#include <limits.h> /* for NGROUPS_MAX */
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
#include <sys/types.h> /* for u_int32_t, if defined */
#include <sys/time.h> /* for struct timeval */
@@ -130,6 +131,8 @@ extern char **script_env; /* Environment variables for scripts */
extern int detached; /* Have detached from controlling tty */
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
extern int ngroups; /* How many groups valid in groups */
+extern struct ppp_stats link_stats; /* byte/packet counts etc. for link */
+extern int link_stats_valid; /* set if link_stats is valid */
/*
* Variables set by command-line options.
@@ -302,6 +305,7 @@ void demand_unblock __P((void)); /* set all NPs to pass packets */
void demand_discard __P((void)); /* set all NPs to discard packets */
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
/* Procedures exported from sys-*.c */
void sys_init __P((void)); /* Do system-dependent initialization */
@@ -337,6 +341,8 @@ void ccp_flags_set __P((int, int, int));
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
int get_idle_time __P((int, struct ppp_idle *));
/* Find out how long link has been idle */
+int get_ppp_stats __P((int, struct ppp_stats *));
+ /* Return link statistics */
int sifvjcomp __P((int, int, int, int));
/* Configure VJ TCP header compression */
int sifup __P((int)); /* Configure i/f up (for IP) */
diff --git a/pppd/sys-NeXT.c b/pppd/sys-NeXT.c
index 0a6645e..7db81d4 100644
--- a/pppd/sys-NeXT.c
+++ b/pppd/sys-NeXT.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-NeXT.c,v 1.15 1999/03/19 01:29:40 paulus Exp $";
+static char rcsid[] = "$Id: sys-NeXT.c,v 1.16 1999/03/19 04:23:46 paulus Exp $";
#endif
#include <stdio.h>
@@ -541,7 +541,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
FD_SET(fd, &in_fds);
if (fd > max_in_fd)
@@ -551,7 +552,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
FD_CLR(fd, &in_fds);
}
@@ -1447,6 +1449,26 @@ get_idle_time(u, ip)
return (ioctl(ttyfd, PPPIOCGIDLE, ip) >= 0);
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ struct ifpppstatsreq req;
+
+ memset (&req, 0, sizeof (req));
+ strlcpy(req.ifr_name, interface, sizeof(req.ifr_name));
+ if (ioctl(sockfd, SIOCGPPPSTATS, &req) < 0) {
+ error("Couldn't get PPP statistics: %m");
+ return 0;
+ }
+ *stats = req.stats;
+ return 1;
+}
+
/*
* get_loop_output - read characters from the loopback, form them
diff --git a/pppd/sys-aix4.c b/pppd/sys-aix4.c
index fbe9bcc..e797c54 100644
--- a/pppd/sys-aix4.c
+++ b/pppd/sys-aix4.c
@@ -21,7 +21,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-aix4.c,v 1.18 1999/03/19 01:29:40 paulus Exp $";
+static char rcsid[] = "$Id: sys-aix4.c,v 1.19 1999/03/19 04:23:46 paulus Exp $";
#endif
/*
@@ -581,7 +581,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
int n;
@@ -599,7 +600,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
int n;
diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c
index 717bcfe..d59f073 100644
--- a/pppd/sys-bsd.c
+++ b/pppd/sys-bsd.c
@@ -21,7 +21,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.39 1999/03/19 01:29:44 paulus Exp $";
+static char rcsid[] = "$Id: sys-bsd.c,v 1.40 1999/03/19 04:23:47 paulus Exp $";
/* $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */
#endif
@@ -559,7 +559,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
FD_SET(fd, &in_fds);
if (fd > max_in_fd)
@@ -569,7 +570,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
FD_CLR(fd, &in_fds);
}
@@ -790,6 +792,26 @@ get_idle_time(u, ip)
return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ struct ifpppstatsreq req;
+
+ memset (&req, 0, sizeof (req));
+ strlcpy(req.ifr_name, interface, sizeof(req.ifr_name));
+ if (ioctl(sockfd, SIOCGPPPSTATS, &req) < 0) {
+ error("Couldn't get PPP statistics: %m");
+ return 0;
+ }
+ *stats = req.stats;
+ return 1;
+}
+
#ifdef PPP_FILTER
/*
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
index 3a5890a..a7fd168 100644
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -966,6 +966,29 @@ get_idle_time(u, ip)
/********************************************************************
*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ struct ifpppstatsreq req;
+
+ memset (&req, 0, sizeof (req));
+
+ req.stats_ptr = (caddr_t) &req.stats;
+ strlcpy(req.ifr__name, ifname, sizeof(req.ifr__name));
+ if (ioctl(sock_fd, SIOCGPPPSTATS, &req) < 0) {
+ error("Couldn't get PPP statistics: %m");
+ return 0;
+ }
+ *stats = req.stats;
+ return 1;
+}
+
+/********************************************************************
+ *
* ccp_fatal_error - returns 1 if decompression was disabled as a
* result of an error detected after decompression of a packet,
* 0 otherwise. This is necessary because of patent nonsense.
diff --git a/pppd/sys-osf.c b/pppd/sys-osf.c
index 30930b2..c25e339 100644
--- a/pppd/sys-osf.c
+++ b/pppd/sys-osf.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-osf.c,v 1.21 1999/03/19 01:29:46 paulus Exp $";
+static char rcsid[] = "$Id: sys-osf.c,v 1.22 1999/03/19 04:23:49 paulus Exp $";
#endif
#include <stdio.h>
@@ -754,7 +754,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
int n;
@@ -772,7 +773,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
int n;
@@ -1009,6 +1011,21 @@ get_idle_time(u, ip)
return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ if (strioctl(pppfd, PPPIO_GETSTAT, stats, 0, sizeof(*stats)) < 0) {
+ error("Couldn't get link statistics: %m");
+ return 0;
+ }
+ return 1;
+}
+
/*
* ccp_fatal_error - returns 1 if decompression was disabled as a
diff --git a/pppd/sys-sunos4.c b/pppd/sys-sunos4.c
index ba2cc3c..8a1847f 100644
--- a/pppd/sys-sunos4.c
+++ b/pppd/sys-sunos4.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-sunos4.c,v 1.16 1999/03/19 01:29:47 paulus Exp $";
+static char rcsid[] = "$Id: sys-sunos4.c,v 1.17 1999/03/19 04:23:50 paulus Exp $";
#endif
#include <stdio.h>
@@ -618,6 +618,44 @@ wait_input(timo)
}
/*
+ * add_fd - add an fd to the set that wait_input waits for.
+ */
+void add_fd(fd)
+ int fd;
+{
+ int n;
+
+ for (n = 0; n < n_pollfds; ++n)
+ if (pollfds[n].fd == fd)
+ return;
+ if (n_pollfds < MAX_POLLFDS) {
+ pollfds[n_pollfds].fd = fd;
+ pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
+ ++n_pollfds;
+ } else
+ error("Too many inputs!");
+}
+
+/*
+ * remove_fd - remove an fd from the set that wait_input waits for.
+ */
+void remove_fd(fd)
+ int fd;
+{
+ int n;
+
+ for (n = 0; n < n_pollfds; ++n) {
+ if (pollfds[n].fd == fd) {
+ while (++n < n_pollfds)
+ pollfds[n-1] = pollfds[n];
+ --n_pollfds;
+ break;
+ }
+ }
+}
+
+#if 0
+/*
* wait_loop_output - wait until there is data available on the
* loopback, for the length of time specified by *timo (indefinite
* if timo is NULL).
@@ -643,7 +681,7 @@ wait_time(timo)
if (n < 0 && errno != EINTR)
fatal("select: %m");
}
-
+#endif
/*
* read_packet - get a PPP packet from the serial device.
@@ -821,6 +859,21 @@ get_idle_time(u, ip)
return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ if (strioctl(pppfd, PPPIO_GETSTAT, stats, 0, sizeof(*stats)) < 0) {
+ error("Couldn't get link statistics: %m");
+ return 0;
+ }
+ return 1;
+}
+
/*
* ccp_fatal_error - returns 1 if decompression was disabled as a
diff --git a/pppd/sys-svr4.c b/pppd/sys-svr4.c
index c87c9d0..461e536 100644
--- a/pppd/sys-svr4.c
+++ b/pppd/sys-svr4.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-svr4.c,v 1.27 1999/03/19 01:29:50 paulus Exp $";
+static char rcsid[] = "$Id: sys-svr4.c,v 1.28 1999/03/19 04:23:52 paulus Exp $";
#endif
#include <limits.h>
@@ -683,7 +683,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
int n;
@@ -701,7 +702,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
int n;
@@ -930,6 +932,21 @@ get_idle_time(u, ip)
return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ if (strioctl(pppfd, PPPIO_GETSTAT, stats, 0, sizeof(*stats)) < 0) {
+ error("Couldn't get link statistics: %m");
+ return 0;
+ }
+ return 1;
+}
+
#if 0
/*
* set_filters - transfer the pass and active filters to the kernel.
diff --git a/pppd/sys-ultrix.c b/pppd/sys-ultrix.c
index e4ed3e7..82783be 100644
--- a/pppd/sys-ultrix.c
+++ b/pppd/sys-ultrix.c
@@ -21,7 +21,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-ultrix.c,v 1.28 1999/03/19 01:29:51 paulus Exp $";
+static char rcsid[] = "$Id: sys-ultrix.c,v 1.29 1999/03/19 04:23:54 paulus Exp $";
#endif
/*
@@ -586,7 +586,8 @@ wait_input(timo)
/*
* add_fd - add an fd to the set that wait_input waits for.
*/
-void add_fd(int fd)
+void add_fd(fd)
+ int fd;
{
FD_SET(fd, &in_fds);
if (fd > max_in_fd)
@@ -596,7 +597,8 @@ void add_fd(int fd)
/*
* remove_fd - remove an fd from the set that wait_input waits for.
*/
-void remove_fd(int fd)
+void remove_fd(fd)
+ int fd;
{
FD_CLR(fd, &in_fds);
}
@@ -793,6 +795,26 @@ get_idle_time(u, ip)
return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct ppp_stats *stats;
+{
+ struct ifpppstatsreq req;
+
+ memset (&req, 0, sizeof (req));
+ strlcpy(req.ifr_name, interface, sizeof(req.ifr_name));
+ if (ioctl(sockfd, SIOCGPPPSTATS, &req) < 0) {
+ error("Couldn't get PPP statistics: %m");
+ return 0;
+ }
+ *stats = req.stats;
+ return 1;
+}
+
/*
* sifvjcomp - config tcp header compression