Monta Vista 2.1: retrive MAC and IP address

Hello Everyone

I am working on Monta Vista 2.1 and writing a application in C code that needs the IP and MAC address of the embedded system. I cannot hardcode this since each system where my application will run might/will have different MAC and IP address.

So my question is if there is anyway for me to in a fast and easy way retrive the MAC and IP from a 2.4.17 Linux kernel and store the result in a string/variable for usage in my C program?

Any hints and tips are welcome.

Regards Andreas

Reply to
Andreas
Loading thread data ...

Hi Andreas,

I haven't explicitly played with the Monta Vista system before, but for the standard linux kernel, you should be able to do an ioctl() to retrieve both.

the ioctrl for the mac address is struct ifreq ifr ioctl(name, SIOCGIFHWADDR, &ifr) and for the IP ioctl(name, SIOCGIFADDR, &ifr) then look in the ifr structure.

should set you in the right direction.

regards

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Damion de Soto - Software Engineer  email:     damion@snapgear.com
 Click to see the full signature
Reply to
Damion de Soto

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.