Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by Christopher R. Zach
Sat, 08 Aug 1992 14:15
Reading Etherent address from C
Author: Christopher R. Zach
Date: Sat, 08 Aug 1992 14:15
Date: Sat, 08 Aug 1992 14:15
9 lines
762 bytes
762 bytes
The subject says it all: How does one get the Ethernet Hardware address into a C program? For that matter, is there any man pages that deal with handling the ethernet drivers? I didn't see anything in the NextDev manuals. Pls reply to cz@silver.lcs.mit.edu, and I will post the results. Chris Zach
Re: Reading Etherent address from C
Author: Fredrik Nyman
Date: Sat, 08 Aug 1992 15:04
Date: Sat, 08 Aug 1992 15:04
24 lines
1125 bytes
1125 bytes
cz@silver.lcs.mit.edu (Christopher R. Zach) writes:
>The subject says it all: How does one get the Ethernet Hardware address into
>a C program?
The program below should do what you want.
And no, I didn't write it, I picked it up on the net in one of
the Sun newsgroups (I think) a couple months ago. Sorry I can't
give credit where it's due,
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
main()
{ char hname[65];
struct ether_addr ea;
gethostname(hname, sizeof(hname));
ether_hostton(hname, &ea);
printf("%s\n", ether_ntoa(&ea));
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads