- don't use if_index to get the number of interfaces in SIOCGIFNUM; compute
the actual number. - forgot to copyout the result in SIOGCIFFLAGS.
This commit is contained in:
parent
02f94c17fb
commit
efc7b8aec4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svr4_sockio.c,v 1.8 1996/04/11 12:54:44 christos Exp $ */
|
||||
/* $NetBSD: svr4_sockio.c,v 1.9 1996/04/22 01:17:33 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Christos Zoulas
|
||||
@ -93,10 +93,34 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
|
||||
switch (cmd) {
|
||||
case SVR4_SIOCGIFNUM:
|
||||
{
|
||||
extern int if_index;
|
||||
struct ifnet *ifp;
|
||||
struct ifaddr *ifa;
|
||||
int ifnum = 0;
|
||||
|
||||
DPRINTF(("SIOCGIFNUM %d\n", if_index));
|
||||
return copyout(&if_index, data, sizeof(if_index));
|
||||
/*
|
||||
* This does not return the number of physical
|
||||
* interfaces (if_index), but the number of interfaces
|
||||
* + addresses like ifconf() does, because this number
|
||||
* is used by code that will call SVR4_SIOCGIFCONF to
|
||||
* find the space needed for SVR4_SIOCGIFCONF. So we
|
||||
* count the number of ifreq entries that the next
|
||||
* SVR4_SIOCGIFCONF will return. Maybe a more correct
|
||||
* fix is to make SVR4_SIOCGIFCONF return only one
|
||||
* entry per physical interface?
|
||||
*/
|
||||
|
||||
for (ifp = ifnet.tqh_first;
|
||||
ifp != 0; ifp = ifp->if_list.tqe_next)
|
||||
if ((ifa = ifp->if_addrlist.tqh_first) == NULL)
|
||||
ifnum++;
|
||||
else
|
||||
for (;ifa != NULL;
|
||||
ifa = ifa->ifa_list.tqe_next)
|
||||
ifnum++;
|
||||
|
||||
|
||||
DPRINTF(("SIOCGIFNUM %d\n", ifnum));
|
||||
return copyout(&ifnum, data, sizeof(ifnum));
|
||||
}
|
||||
|
||||
case SVR4_SIOCGIFFLAGS:
|
||||
@ -109,13 +133,16 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
|
||||
|
||||
(void) strcpy(br.ifr_name, sr.svr4_ifr_name);
|
||||
if ((error = (*ctl)(fp, SIOCGIFFLAGS,
|
||||
(caddr_t) &br, p)) != 0)
|
||||
(caddr_t) &br, p)) != 0) {
|
||||
DPRINTF(("SIOCGIFFLAGS %s: error %d\n",
|
||||
sr.svr4_ifr_name, error));
|
||||
return error;
|
||||
}
|
||||
|
||||
sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags);
|
||||
DPRINTF(("SIOCGIFFLAGS %s = %d\n",
|
||||
DPRINTF(("SIOCGIFFLAGS %s = %x\n",
|
||||
sr.svr4_ifr_name, sr.svr4_ifr_flags));
|
||||
return 0;
|
||||
return copyout(&sr, data, sizeof(sr));
|
||||
}
|
||||
|
||||
case SVR4_SIOCGIFCONF:
|
||||
@ -125,6 +152,10 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
|
||||
if ((error = copyin(data, &sc, sizeof(sc))) != 0)
|
||||
return error;
|
||||
|
||||
DPRINTF(("ifreq %d svr4_ifreq %d ifc_len %d\n",
|
||||
sizeof(struct ifreq), sizeof(struct svr4_ifreq),
|
||||
sc.svr4_ifc_len));
|
||||
|
||||
if ((error = (*ctl)(fp, OSIOCGIFCONF,
|
||||
(caddr_t) &sc, p)) != 0)
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user