lkml.org 
[lkml]   [1999]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: ioctl SIOCGIFADDR bug
Date
In article <199908052031.QAA29714@smtp3.mindspring.com> you wrote:
> struct ifreq ifr;
> inet_sock = socket(AF_INET, SOCK_DGRAM, 0);
> strcpy(ifr.ifr_name, "eth0");
> if (ioctl(inet_sock, SIOCGIFADDR, &ifr) < 0)
> perror("zzz: ioctl");

You need to set the address family before you read smething.

Thats why ifconfig does not suffer from it:
strcpy(ifr.ifr_name, ifname);
ifr.ifr_addr.sa_family = AF_INET;
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.026 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site