All of lore.kernel.org
 help / color / mirror / Atom feed
* Gettin own IP address thorugh ioctl in kernel space.
@ 2006-07-19  9:33 Chinmaya Mishra
  2006-07-19  9:52 ` Parag N(पराग़)
  2006-07-19 11:56 ` Erik Mouw
  0 siblings, 2 replies; 5+ messages in thread
From: Chinmaya Mishra @ 2006-07-19  9:33 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 keernel space.

Thank you.
Chinmaya



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-19 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-19  9:33 Gettin own IP address thorugh ioctl in kernel space Chinmaya Mishra
2006-07-19  9:52 ` Parag N(पराग़)
2006-07-19 11:56 ` Erik Mouw
2006-07-19 15:07   ` Jan Engelhardt
2006-07-19 15:23     ` Valdis.Kletnieks

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.