[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20060719115629.GB22306@harddisk-recovery.com>
Date: Wed, 19 Jul 2006 13:56:29 +0200
From: Erik Mouw <erik@...ddisk-recovery.com>
To: chinmaya@...omedia.soft.net
Cc: Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: Gettin own IP address thorugh ioctl in kernel space.
On Wed, Jul 19, 2006 at 03:03:24PM +0530, Chinmaya Mishra wrote:
> Can you provide an example how to invoke ioctl on
> device in kernel module.
>
> For example. I want to find out the IP address of
> my eth0 and I want to make SIOCSIFADDR on it from
> kernel module.
Sounds like a badly designed module. Do it from userspace.
> At user space i am doing it like this.....
>
> unsigned long *ip;
> char *iface;
> int sockfd;
> struct ifreq ifr;
> strcpy(ifr.ifr_name, iface); // interface name 'eth0'
> sockfd = socket(AF_INET,SOCK_DGRAM,0);
> ioctl(sockfd, SIOCGIFADDR, (char*)&ifr);
> memcpy(ip, &(ifr.ifr_addr.sa_data[2]),4); //Copy the ip addr
> close(sockfd);
>
> How to port this in keernel space.
Not. For the same reasons why you shouldn't read files from kernel
space.
Erik
--
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists