Nevermind all...
i figured it out (printing human readable MAC address).
for (i=0; i<8; ++i) printf(".%d", ethaddr[i]);
thanks for all your help. Now i just need to figure out how to do the same
thing with the ip address :)
-Andy
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kenneth
> Johansson
> Sent: Wednesday, December 20, 2000 8:46 AM
> To: Andy Angrick
> Cc: Luc Hermans; [EMAIL PROTECTED]
> Subject: Re: Retrieving IP/MAC
>
>
> Andy Angrick wrote:
>
> > Where can i find getHWaddr??
> >
> > -Andy
> >
>
> I don't know I think its a windows thing but maybe this works to
> You should probably change this so it is reentrant.
> ----
>
> char *gethwaddr(char *device)
> {
> int fd;
> static char ethaddr[8];
> struct ifreq ifr;
>
> if((fd=socket(AF_INET,SOCK_DGRAM,0))<0)
> return 0;
> memset(&ifr,0,sizeof(ifr));
> strncpy(ifr.ifr_name,device,sizeof(ifr.ifr_name));
> if(ioctl(fd,SIOCGIFHWADDR,(char *)&ifr)==-1)
> {
> close(fd);
> return 0;
> }
> close(fd);
> memcpy(ethaddr,&ifr.ifr_hwaddr.sa_data,ETHER_ADDR_LEN);
> return ethaddr;
> }
>
>
>
>
--
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the command "unsubscribe linux-embedded" in the message body.
For more information, see <http://waste.org/mail/linux-embedded>.