Monta Vista 2.1: retrive MAC and IP address

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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.


Re: Monta Vista 2.1: retrive MAC and IP address
Hi Andreas,

Quoted text here. Click to load it

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.


Damion de Soto - Software Engineer  email:
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline