• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to get the Mac address of a host on LAN by its IP on MAC-OS-X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get the Mac address of a host on LAN by its IP on MAC-OS-X


  • Subject: How to get the Mac address of a host on LAN by its IP on MAC-OS-X
  • From: Kan Cheng <email@hidden>
  • Date: Mon, 22 Oct 2007 23:29:32 -0700
  • Acceptlanguage: en-US
  • Thread-topic: How to get the Mac address of a host on LAN by its IP on MAC-OS-X

Hello all,

I’m writing a program on Mac-OS-X to get the Mac address(hardware address) of a host on LAN according to its IP, so I try to use socket with ARP protocol to make it.

But things does not works as I expected:

 

n   when I was constructing the socket on Mac-OS-X , like doing the same thing on Linux:

…

     int fd_arp;

     if((fd_arp = socket(AF_INET,   SOCK_SEQPACKET,   htons(0x0806)))   <   0)

     {

           perror("socket error");

           goto _ERROR_HANDLER;

     }

                …

I got the error message on console: ‘socket error: Protocol not supported’. But when I open /etc/protocols, I found that NARP & LARP were declared.

 

àDoes it means Mac-OS-X socket does not support ARP?  Is there any way to make it work?

 

n  When I trying to use the command “arp –a” on the terminal, I can get some of the hosts on the LAN cannot get all of them. Even more, when I use the tool ettercap with the command “./ettercap -l”, ettercap can only list out my own host on LAN but cannot find the others, which confuses me a lot –

 

àCan anyone here tell me why the arp and ettercap tools cannot work as we expected?

 

n  I’m trying to open device ‘/dev/bpf%d’ and use write()/read() to send/receive ARP packet directly. But I also cannot get the reply packet as I expected.

 

àCan anyone kindly show me some guideline to make it work in this way or show me other programming ways on Mac-OS-X to get the Mac address of a host by its IP?

 

Thanks a lot!

 

Best Regards

Kan Cheng

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: DNS setup
  • Next by Date: Re: MoreSCF 1.1 and Cross-Development
  • Previous by thread: Re: DNS setup
  • Next by thread: Re: How to get the Mac address of a host on LAN by its IP on MAC-OS-X
  • Index(es):
    • Date
    • Thread