|
||||||||
|
|
#1
|
|
Hi all,
I have an IP Address, and I'm sure, that the corresponding MAC Address is inside the ARP cache. Is there a C-Function to get the MAC Address? Regards Dirk =?ISO-8859-1?Q?Dirk_F=F6rster?= |
|
#2
|
|||
|
|||
|
Dirk Förster wrote:
> Hi all, > > I have an IP Address, and I'm sure, that the corresponding MAC Address > is inside the ARP cache. > Is there a C-Function to get the MAC Address? Your mac address will not be in the arp cache of your computer. It only lists the mac of other computers. -- Fundamentalism is fundamentally wrong. To reply to this message, replace everything to the left of "@" with james.knott. |
|
#3
|
|||
|
|||
|
James Knott wrote:
> Dirk Förster wrote: > > >>Hi all, >> >>I have an IP Address, and I'm sure, that the corresponding MAC Address >>is inside the ARP cache. >>Is there a C-Function to get the MAC Address? > > > Your mac address will not be in the arp cache of your computer. It only > lists the mac of other computers. > That's right. The IP Address I have is the next hop Address. And I know, that there was an ARP request before.I want to read out the corresponding MAC Address. |
|
#4
|
|||
|
|||
|
On Mon, 10 Nov 2003 13:09:44 +0100, Dirk Förster wrote:
> James Knott wrote: >> Dirk Förster wrote: >> >> >>>Hi all, >>> >>>I have an IP Address, and I'm sure, that the corresponding MAC Address >>>is inside the ARP cache. >>>Is there a C-Function to get the MAC Address? >> >> >> Your mac address will not be in the arp cache of your computer. It only >> lists the mac of other computers. >> > That's right. > The IP Address I have is the next hop Address. And I know, that there > was an ARP request before.I want to read out the corresponding MAC Address. Try ifconfig, arp and arping. For more info the man pages can come handy. Rudi Swennen |
|
#5
|
|||
|
|||
|
Dirk Förster wrote:
> Hi all, > > I have an IP Address, and I'm sure, that the corresponding MAC Address > is inside the ARP cache. > Is there a C-Function to get the MAC Address? See, man 7 arp FWIW, when looking for assistance with Linux programming tasks, the Linux programming newsgroups and mailing lists are generally your best bet, e.g., comp.os.linux.development.* -- Jim To reply by email, remove "link" and change "now.here" to "yahoo" jfischer_link5809{at}now.here.com |
|
#6
|
|||
|
|||
|
I had a similar question and googled around until I
found the following ioctl. Hope this helps.... /* Try to find an entry in arp cache for the ip address specified */ printf("Find arp entry for IP : %s\n", ip); sin = (struct sockaddr_in *) &arpreq.arp_pa; memset(sin, 0, sizeof(struct sockaddr_in)); sin->sin_family = AF_INET; ina.s_addr = inet_addr(ip); memcpy(&sin->sin_addr, (char *)&ina, sizeof(struct in_addr)); strcpy(arpreq.arp_dev, "eth0"); arpreq.arp_ha.sa_family = AF_UNSPEC; /* rc = ioctl(sd, SIOCGARP, &arpreq); if (rc < 0) { perror("Entry not available in cache. Sending arp req...\n"); send_arp_req(ip); rc = ioctl(sd, SIOCGARP, &arpreq); if (rc < 0) { printf("No arp reply. \n"); exit(1); } } */ send_arp_req(ip); rc = ioctl(sd, SIOCGARP, &arpreq); if (rc < 0) { printf("No arp reply. \n"); exit(1); } hw_addr = (unsigned char *) arpreq.arp_ha.sa_data; printf("HWAddr found : %x:%x:%x:%x:%x:%x\n", hw_addr[0], hw_addr[1], hw_addr[2], hw_addr[3], hw_addr[4], hw_addr[5]); return 1; } void send_arp_req(char *ip_addr) { /* Sending the arp Request here */ } Dirk Förster wrote: > Hi all, > > I have an IP Address, and I'm sure, that the corresponding MAC Address > is inside the ARP cache. > Is there a C-Function to get the MAC Address? > > Regards > Dirk > |
![]() |
| Tags |
| access, arp, cache |
| Thread Tools | |
| Display Modes | |
|
|