get_myaddress() wasn't following the interface array properly
Cannidate for: 2.2
This commit is contained in:
parent
97e7497033
commit
b63c62d830
@ -30,7 +30,7 @@
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
|
||||
/*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/
|
||||
static char *rcsid = "$Id: get_myaddress.c,v 1.3 1995/10/22 14:51:23 phk Exp $";
|
||||
static char *rcsid = "$Id: get_myaddress.c,v 1.4 1996/06/08 22:54:51 jraynard Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -60,8 +60,7 @@ void get_myaddress(addr)
|
||||
int s;
|
||||
char buf[BUFSIZ];
|
||||
struct ifconf ifc;
|
||||
struct ifreq ifreq, *ifr;
|
||||
int len, slop;
|
||||
struct ifreq ifreq, *ifr, *end;
|
||||
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
perror("get_myaddress: socket");
|
||||
@ -74,7 +73,9 @@ void get_myaddress(addr)
|
||||
exit(1);
|
||||
}
|
||||
ifr = ifc.ifc_req;
|
||||
for (len = ifc.ifc_len; len; len -= sizeof ifreq) {
|
||||
end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
|
||||
|
||||
while (ifr < end) {
|
||||
ifreq = *ifr;
|
||||
if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
|
||||
perror("get_myaddress: ioctl");
|
||||
@ -86,14 +87,10 @@ void get_myaddress(addr)
|
||||
addr->sin_port = htons(PMAPPORT);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Deal with variable length addresses
|
||||
*/
|
||||
slop = ifr->ifr_addr.sa_len - sizeof (struct sockaddr);
|
||||
if (slop) {
|
||||
ifr = (struct ifreq *) ((caddr_t)ifr + slop);
|
||||
len -= slop;
|
||||
}
|
||||
if (ifr->ifr_addr.sa_len)
|
||||
ifr = (struct ifreq *) ((caddr_t) ifr +
|
||||
ifr->ifr_addr.sa_len -
|
||||
sizeof(struct sockaddr));
|
||||
ifr++;
|
||||
}
|
||||
(void) close(s);
|
||||
|
Loading…
Reference in New Issue
Block a user