summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/os.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-05-11 20:48:42 +0000
committerphk <phk@FreeBSD.org>1996-05-11 20:48:42 +0000
commit324cb686d3d54b8549afe3d7b81a3727b677b86f (patch)
tree2eb51c7c6b624bca2272b302022a11fdd68760c6 /usr.sbin/ppp/os.c
parent3683fd396bd99a9421c45c0f109d8430e49a7e4c (diff)
downloadFreeBSD-src-324cb686d3d54b8549afe3d7b81a3727b677b86f.zip
FreeBSD-src-324cb686d3d54b8549afe3d7b81a3727b677b86f.tar.gz
Here is a diff of /usr/src/usr.sbin/ppp against current. The diffs
add some logging functionality which I find very useful. 'set debug link' will record just link up/down and address assignments. 'set debug connect' will record the entire chat dialog 'set debug carrier' will record just chat lines including 'CARRIER' (so that I can be sure I'm getting a 28.8 line). There was a global change required to permit LogPrintf to take a bit mask instead of a bit position value (to permit logging some events on either of two flags, so that no change in 'set debug lcp' would result from the code supporting 'link'. Thus the diffs are rather long for such a small change. The man page is also touched. Oh, and there was a slight syntax problem in route.c Reviewed by: phk Submitted by: Tony Kimball <alk@Think.COM>
Diffstat (limited to 'usr.sbin/ppp/os.c')
-rw-r--r--usr.sbin/ppp/os.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c
index 691e258..f42318d 100644
--- a/usr.sbin/ppp/os.c
+++ b/usr.sbin/ppp/os.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.c,v 1.3 1995/05/30 03:50:52 rgrimes Exp $
+ * $Id: os.c,v 1.4 1996/01/11 17:48:55 phk Exp $
*
*/
#include "fsm.h"
@@ -181,7 +181,7 @@ OsLinkup()
logprintf("setuid failed\n");
peer_addr = IpcpInfo.his_ipaddr;
s = (char *)inet_ntoa(peer_addr);
- LogPrintf(LOG_PHASE, "OsLinkup: %s\n", s);
+ LogPrintf(LOG_LINK_BIT|LOG_LCP_BIT, "OsLinkup: %s\n", s);
if (SelectSystem(inet_ntoa(IpcpInfo.want_ipaddr), LINKFILE) < 0) {
if (dstsystem) {
@@ -201,7 +201,7 @@ OsLinkdown()
if (linkup) {
s = (char *)inet_ntoa(peer_addr);
- LogPrintf(LOG_PHASE, "OsLinkdown: %s\n", s);
+ LogPrintf(LOG_LINK_BIT|LOG_LCP_BIT, "OsLinkdown: %s\n", s);
if (!(mode & MODE_AUTO))
DeleteIfRoutes(0);
linkup = 0;
@@ -253,25 +253,35 @@ int type, mtu, speed;
/*
* Open tunnel device and returns its descriptor
*/
+
+#define MAX_TUN 256
+/* MAX_TUN is set at an arbitrarily large value *
+ * as the loop aborts when it reaches the first *
+ * 'Device not configured' (ENXIO), or the third *
+ * 'No such file or directory' (ENOENT) error. */
int
OpenTunnel(ptun)
int *ptun;
{
int s;
- char *cp;
- char *suffix = "0123456789";
char ifname[IFNAMSIZ];
- char devname[12];
+ char devname[14]; /* sufficient room for "/dev/tun65535" */
+ unsigned unit, enoentcount=0;
- strcpy(devname, "/dev/tun0");
- for (cp = suffix; *cp; cp++) {
- devname[8] = *cp;
+ for( unit=0; unit <= MAX_TUN ; unit++ ) {
+ sprintf( devname, "/dev/tun%d", unit );
tun_out = open(devname, O_RDWR);
- if (tun_out >= 0)
- break;
+ if( tun_out >= 0 )
+ break;
+ if( errno == ENXIO )
+ unit=MAX_TUN+1;
+ else if( errno == ENOENT ) {
+ enoentcount++;
+ if( enoentcount > 2 )
+ unit=MAX_TUN+1;
+ }
}
- *ptun = cp - suffix;
- if (*cp == '\0') {
+ if( unit > MAX_TUN ) {
fprintf(stderr, "No tunnel device is available.\n");
return(-1);
}
@@ -317,7 +327,7 @@ int *ptun;
return(-1);
}
printf("Using interface: %s\r\n", IfDevName);
- LogPrintf(LOG_PHASE, "Using interface: %s\n", IfDevName);
+ LogPrintf(LOG_PHASE_BIT, "Using interface: %s\n", IfDevName);
close(s);
return(0);
}
OpenPOWER on IntegriCloud