Re: Confusing ifreq behavior: guru needed

Tony Cook (kernel@cook.ml.org)
Tue, 13 Oct 1998 21:34:12 +1000 (EST)


On Mon, 12 Oct 1998, B. James Phillippe wrote:

> Hello,
>
> I'll be concise: I am writing some user-space code that needs to
> obtain the IPv4 protocol address and hardware address from an interface
> (arbitrary). I am using the ioctl() method with SIOCGIFHWADDR and
> SIOCGIFADDR, operating on struct ifreq (contains struct sockaddr). The
> hardware address part works like I expect. But the IP address doesn't;
> it's stored in sa_data, offset two bytes. I don't understand why. Here is
> a code pseudo-fragment:

The result of SIOCGIFADDR is a struct sockaddr, or for an INET socket a
struct sockaddr_in, which has an (unused) port number at the front.

-
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/