Access to ARP Cache

This is a discussion on Access to ARP Cache within the Linux Networking forums, part of the Linux Forums category; Hi all, I have an IP Address, and I'm sure, that the corresponding MAC Address is inside the ARP ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-10-2003
Dirk Förster
 
Posts: n/a
Default Access to ARP Cache

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

Reply With Quote
  #2 (permalink)  
Old 11-10-2003
James Knott
 
Posts: n/a
Default Re: Access to ARP Cache

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.
Reply With Quote
  #3 (permalink)  
Old 11-10-2003
Dirk Förster
 
Posts: n/a
Default Re: Access to ARP Cache

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.

Reply With Quote
  #4 (permalink)  
Old 11-10-2003
Rudi Swennen
 
Posts: n/a
Default Re: Access to ARP Cache

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
Reply With Quote
  #5 (permalink)  
Old 11-11-2003
Jim Fischer
 
Posts: n/a
Default Re: Access to ARP Cache

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


Reply With Quote
  #6 (permalink)  
Old 11-12-2003
Bob Smith
 
Posts: n/a
Default Re: Access to ARP Cache

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
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0