diff options
author | jkh <jkh@FreeBSD.org> | 1996-10-06 13:32:37 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1996-10-06 13:32:37 +0000 |
commit | 0126fef03c77e24d10287500630a8937927af05c (patch) | |
tree | ad8d5fd7602ec7777833a137bea28011b2ce01d8 /usr.sbin/ppp/route.c | |
parent | d4df49b545734e1261c785b09fbba51dfabdd053 (diff) | |
download | FreeBSD-src-0126fef03c77e24d10287500630a8937927af05c.zip FreeBSD-src-0126fef03c77e24d10287500630a8937927af05c.tar.gz |
Add support for the Evil Microsoft ppp extentions. Yes, they did it
on their own without even attempting to get concensus in the IETF, but
there are also lots of Win95/NT boxes out there.
CLoses PR#1494
Submitted-By: Peter Childs <pjchilds@imforei.apana.org.au>
Diffstat (limited to 'usr.sbin/ppp/route.c')
-rw-r--r-- | usr.sbin/ppp/route.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 23ad578..b9570fa 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.6 1996/05/11 20:48:42 phk Exp $ + * $Id: route.c,v 1.7 1996/08/13 09:19:45 peter Exp $ * */ #include <sys/types.h> @@ -351,14 +351,20 @@ int all; free(sp); } + /* + * 960603 - Modified to use dynamic buffer allocator as in ifconfig + */ + int GetIfIndex(name) char *name; { + char *buffer; struct ifreq *ifrp; int s, len, elen, index; struct ifconf ifconfs; - struct ifreq reqbuf[32]; + /* struct ifreq reqbuf[256]; -- obsoleted :) */ + int oldbufsize, bufsize = sizeof(struct ifreq); s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { @@ -366,12 +372,27 @@ char *name; return(-1); } - ifconfs.ifc_len = sizeof(reqbuf); - ifconfs.ifc_buf = (caddr_t)reqbuf; - if (ioctl(s, SIOCGIFCONF, &ifconfs) < 0) { - perror("IFCONF"); - return(-1); - } + buffer = malloc(bufsize); /* allocate first buffer */ + ifconfs.ifc_len = bufsize; /* Initial setting */ + /* + * Iterate through here until we don't get many more data + */ + + do { + oldbufsize = ifconfs.ifc_len; + bufsize += 1+sizeof(struct ifreq); + buffer = realloc((void *)buffer, bufsize); /* Make it bigger */ +#ifdef DEBUG + logprintf ("Growing buffer to %d\n", bufsize); +#endif + ifconfs.ifc_len = bufsize; + ifconfs.ifc_buf = buffer; + if (ioctl(s, SIOCGIFCONF, &ifconfs) < 0) { + perror("IFCONF"); + free(buffer); + return(-1); + } + } while (ifconfs.ifc_len > oldbufsize); ifrp = ifconfs.ifc_req; @@ -385,6 +406,7 @@ char *name; #endif if (strcmp(ifrp->ifr_name, name) == 0) { IfIndex = index; + free(buffer); return(index); } index++; @@ -396,5 +418,6 @@ char *name; } close(s); + free(buffer); return(-1); } |