* How to get the IP address in kernel module
@ 2006-07-19 9:53 Chinmaya Mishra
0 siblings, 0 replies; only message in thread
From: Chinmaya Mishra @ 2006-07-19 9:53 UTC (permalink / raw)
To: Linux Kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-07-19 9:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-19 9:53 How to get the IP address in kernel module Chinmaya Mishra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.