fixed get_ip_by_ifname bug (not found of interfaces on odd place (1, 3, 5)

This commit is contained in:
Thomas Ries
2002-12-06 19:30:25 +00:00
parent 051c9dab99
commit e3ef83a413
+4 -4
View File
@@ -440,10 +440,10 @@ int get_ip_by_ifname(char *ifname, struct in_addr *retaddr) {
* seems to have disapeared on 2.4 (RH7)
* len=SA_LEN((struct sockaddr *)&ifr->ifr_addr);
*/
len=sizeof(struct ifreq);
len=IFNAMSIZ;
#endif
af=((struct sockaddr *)&ifr->ifr_addr)->sa_family;
i+=len+IFNAMSIZ;
i+=len;
if(af != AF_INET) continue;
DEBUG("[i=%i] IF %s, l=%i af=%i -> IP:%s", i,
@@ -465,10 +465,10 @@ int get_ip_by_ifname(char *ifname, struct in_addr *retaddr) {
* seems to have disapeared on 2.4 (RH7)
* len=SA_LEN((struct sockaddr *)&ifr->ifr_addr);
*/
len=sizeof(struct ifreq);
len=IFNAMSIZ;
#endif
af=((struct sockaddr *)&ifr->ifr_addr)->sa_family;
i+=len+IFNAMSIZ;
i+=len;
if(af != AF_INET) continue;
if (strcmp(ifr->ifr_name, ifname)==0) {