I am making a module in which I require the mac address of network interface . Is there any function through which I can find the mac address without doing ioctl in user space.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t specify which kernel version you’re using. This is based on the latest 3.something version, but it should be very similar for older versions:
Assuming you have the struct net_device (and if you don’t, you’re probably doing something wrong), you can just look at the dev_addrs field. It contains a list of all of the devices hardware addresses.
The is_etherdev_addr function in include/linux/etherdevice.h is probably a good example on how to read it.