lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Using ARP to get MAC address


From: Tomas Daujotas
Subject: Re: [lwip-users] Using ARP to get MAC address
Date: Fri, 17 Feb 2012 11:43:39 +0200

On Fri, Feb 17, 2012 at 10:57 AM, Simon Goldschmidt <address@hidden> wrote:
>
> > I am trying to get destination MAC address, when I know destination IP
> > address for my packet offload mechanism.
>
> I'm not sure that the etharp module exposes the correct functions to do what 
> you want. The information should however be available in the arp cache. Using 
> etharp_query() sounds correct (since you do want to send a query). Using 
> etharp_find_addr() also sounds correct but I don't know why it would procude 
> a gratuitous arp. I should only search the ARP table.
>
> I guess first using etharp_query() to issue the request and then repeatedly 
> using etharp_find_addr() to search the ARP table for the address should be 
> the way to go. Maybe you need to re-issue the request with a timeout if you 
> don't get a response.

Yes, that's a logical solution and I am trying to do exact thing as
You've said, but etharp_find_addr() always returns -1. Let's check
what we have inside:

s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, struct
eth_addr **eth_ret, ip_addr_t **ip_ret) {

  s8_t i;

  LWIP_ASSERT("eth_ret != NULL && ip_ret != NULL", eth_ret != NULL &&
ip_ret != NULL);

  LWIP_UNUSED_ARG(netif);

  i = find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY);

  if((i >= 0) && arp_table[i].state == ETHARP_STATE_STABLE) {
      *eth_ret = &arp_table[i].ethaddr;
      *ip_ret = &arp_table[i].ipaddr;
      return i;
  }

  return -1;
}

Seems like find_entry() doesn't give any results at all... Well,
actually, it returns 0.

Strange, I've placed print out just after the find_entry() beginning:
  for (i = 0; i < ARP_TABLE_SIZE; i++)  printf("ARP Table: i=%d \t
state=%d \t ip=0x%08X \n",i,arp_table[i].state,arp_table[i].ipaddr);

And it succesfully prints me the required result in the first place
after the first ARP reception, state becomes 1 and arp_table[i].ipaddr
gives a required result. So table is updated. I need to get MAC
somewhere now.

P.S. I don't understand what's the point of pointer ip_ret in
etharp_find_addr() if I already give the IP address to the function as
an argument?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]