🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #505

Re: Reading Etherent address from C

#505
From: Fredrik Nyman
Date: Sat, 08 Aug 1992 15:04
24 lines
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));
}
Technical Details
Message-ID: <1992Aug8.150425.14099@socrates.umd.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!haven.umd.edu!socrates!ice
References: <1992Aug8.141559.212@mintaka.lcs.mit.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!haven.umd.edu!socrates!ice
From: ice@socrates.umd.edu (Fredrik Nyman)
Subject: Re: Reading Etherent address from C
Message-ID: <1992Aug8.150425.14099@socrates.umd.edu>
Organization: University of Maryland University College
References: <1992Aug8.141559.212@mintaka.lcs.mit.edu>
Distribution: usa
Date: Sat, 8 Aug 1992 15:04:25 GMT
Lines: 25