Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
Monta Vista 2.1: retrive MAC and IP address
- 10-17-2003
October 17, 2003, 3:08 am

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
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

Re: Monta Vista 2.1: retrive MAC and IP address

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: snipped-for-privacy@snapgear.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Damion de Soto - Software Engineer email: snipped-for-privacy@snapgear.com
We've slightly trimmed the long signature. Click to see the full one.
Site Timeline
- » Embedded linux on a PCI cpu card?
- — Next thread in » Embedded Linux
-
- » linux kernel interfacing with USB host
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » La folie des mesures ?
- — The site's Newest Thread. Posted in » Electronics (French)
-