Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.hawaii.edu!news.uoregon.edu!vixen.cso.uiuc.edu!howland.erols.net!newsfeed.internetmci.com!in3.uu.net!netnews.worldnet.att.net!ix.netcom.com!netcom.net.uk!dispatch.news.demon.net!demon!arg1.demon.co.uk
From: Andrew Gordon <andrew.gordon@net-tel.co.uk>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: tun device not available.....
Date: Sun, 18 Aug 1996 00:07:44 GMT
Lines: 58
Message-ID: <840326864.8170.0@arg1.demon.co.uk>
References: <4v3f8e$u8a@news3.realtime.net>
NNTP-Posting-Host: arg1.demon.co.uk
X-NNTP-Posting-Host: arg1.demon.co.uk
X-Mailer: Mozilla 1.1N (X11; I; FreeBSD 2.1.5-RELEASE i386)
MIME-Version: 1.0
To: tushar@ecpi.com
X-URL: news:4v3f8e$u8a@news3.realtime.net
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
tushar@ecpi.com (Tushar Patel) wrote:
>Hi,
>
>I tried following suggestion give by Jorden, still when I try to connect
>on the 11th line I get message saying no tun device available.
If you look at the source, you will observe that src/sys/usr.sbin/ppp/os.c
doesn't cope with more than 10 devices. The following patch (untested) might
fix this - try it and see:
diff -c -r1.3.4.2 os.c
*** os.c 1996/06/03 21:39:23 1.3.4.2
--- os.c 1996/08/18 00:03:44
***************
*** 260,279 ****
int *ptun;
{
int s;
! char *cp;
! char *suffix = "0123456789";
char ifname[IFNAMSIZ];
char devname[12];
! strcpy(devname, "/dev/tun0");
! for (cp = suffix; *cp; cp++) {
! devname[8] = *cp;
tun_out = open(devname, O_RDWR);
if (tun_out >= 0)
break;
}
! *ptun = cp - suffix;
! if (*cp == '\0') {
fprintf(stderr, "No tunnel device is available.\n");
return(-1);
}
--- 260,279 ----
int *ptun;
{
int s;
! int if_no;
char ifname[IFNAMSIZ];
char devname[12];
! for (if_no = 0; ; if_no++) {
! sprintf(devname, "/dev/tun%d", if_no);
tun_out = open(devname, O_RDWR);
if (tun_out >= 0)
break;
+ if (errno == ENOENT)
+ break;
}
! *ptun = if_no;
! if (tun_out < 0) {
fprintf(stderr, "No tunnel device is available.\n");
return(-1);
}