Gettin own IP address thorugh ioctl in kernel space.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux