Networking Forums

Networking Forums > Computer Networking > Linux Networking > Access to ARP Cache

Reply
Thread Tools Display Modes

Access to ARP Cache

 
 
=?ISO-8859-1?Q?Dirk_F=F6rster?=
Guest
Posts: n/a

 
      11-10-2003, 10:44 AM
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
 
 
 
 
James Knott
Guest
Posts: n/a

 
      11-10-2003, 10:51 AM
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
 
=?ISO-8859-15?Q?Dirk_F=F6rster?=
Guest
Posts: n/a

 
      11-10-2003, 11:09 AM
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
 
Rudi Swennen
Guest
Posts: n/a

 
      11-10-2003, 11:50 AM
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
 
Jim Fischer
Guest
Posts: n/a

 
      11-10-2003, 11:10 PM
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
 
Bob Smith
Guest
Posts: n/a

 
      11-12-2003, 11:07 AM
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
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DNS cache tshad Windows Networking 3 01-18-2007 10:59 PM
DNS cache McG Wireless Networks 0 01-08-2006 01:30 PM
cache june Broadband 3 07-06-2005 09:53 PM
arp cache cb39940 Wireless Networks 3 06-26-2005 01:22 AM
ISP cache Schewdent Linux Networking 3 08-02-2004 09:08 AM



1 2 3 4 5 6 7 8 9 10 11