lkml.org 
[lkml]   [2006]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectHow to get the IP address in kernel module
From
Hi,

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.


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 kernel space.

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

\
 
 \ /
  Last update: 2006-07-19 11:51    [W:0.037 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site