Hello,

Thnks;

I was wrong and you are right : ioctls are really inefficient in this case.

Regards,
Amir

From: Baruch Even <[EMAIL PROTECTED]>
To: Amir Binyamini <[EMAIL PROTECTED]>
CC: [email protected]
Subject: Re: Getting the IP address of eth0 in a kernel module
Date: Thu, 30 Jun 2005 14:00:10 +0100

Amir Binyamini wrote:
> Hello,
>       Is there a way to get in a kernel module the ip address which is
> assigned
>       to eth0 ?

First, you want the struct net_device *, use dev_get_by_name(), find it
in include/linux/netdevice.h

Use __in_dev_get() to convert the net_device to 'struct in_device *'. To
do it properly you'll use in_dev_get() and when you finish with it use
in_dev_put().

Use for_primary_ifa(in_dev) to search the primary addresses of the device.

>      (for the simplicity let's assume that there is only eth0 and no
>      eth0:1 and so on  ; and that there is another ethN (where N>1).
>
>      I of course know about the ifconfig of net-tools, but this
> is a user space app which opens a socket; I want to get the IP address
>     of eth0 in a module in kernel space
>
>     I assume that there is an IOCTL call which does this but googling
>     did not gave much success.

IOCTLs? inside the kernel? It might be possible but you are in the
kernel, so you have access to the kernel data structures...

Besides, using netlink is the right way.

Baruch

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.com/


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to