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