lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Problems with a HTTP server - etharp.c - v2.1.2


From: stevestrong
Subject: [lwip-users] Problems with a HTTP server - etharp.c - v2.1.2
Date: Thu, 3 Jan 2019 08:03:19 -0700 (MST)

Hi all,

I am currently experiencing problems with a HTTP server based on STM32070
package, wherein I updated the LwIP source to  v2.1.2
<http://download.savannah.nongnu.org/releases/lwip/lwip-2.1.2.zip>  .

The issue is that after the DHCP gets an IP address acknowledged by the
router, the STM32 board is not reachable under that address from my client
PC.

I attach a wireshark log and a serial debug log.
dhcp4.pcap <http://lwip.100.n7.nabble.com/file/t2167/dhcp4.pcap>  
dhcp4.jpg <http://lwip.100.n7.nabble.com/file/t2167/dhcp4.jpg>  
dhcp4.log <http://lwip.100.n7.nabble.com/file/t2167/dhcp4.log>  

The debug log contains PC timestamps and system timestamps meaning the
milliseconds since start, implemented also for sys_now().

Trying to find the root cause in the source files, I observed some strange
code in lines 682 to 717 of etharp.c:
etharp.c <http://lwip.100.n7.nabble.com/file/t2167/etharp.c>  
****************************************************
...
  /* this interface is not configured? */
[l_682:]
  if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
    for_us = 0;
  } else {
    /* ARP packet directed to us? */
    for_us = (u8_t)ip4_addr_cmp(&dipaddr, netif_ip4_addr(netif));
  }

  /* ARP message directed to us?
      -> add IP address in ARP cache; assume requester wants to talk to us,
         can result in directly sending the queued packets for this host.
     ARP message not directed to us?
      ->  update the source IP address in the cache, if present */
  etharp_update_arp_entry(netif, &sipaddr, &(hdr->shwaddr),
                          for_us ? ETHARP_FLAG_TRY_HARD :
ETHARP_FLAG_FIND_ONLY);

  /* now act on the message itself */
  switch (hdr->opcode) {
    /* ARP request? */
    case PP_HTONS(ARP_REQUEST):
      /* ARP request. If it asked for our address, we send out a
       * reply. In any case, we time-stamp any existing ARP entry,
       * and possibly send out an IP packet that was queued on it. */

      LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: incoming
ARP request\n"));
      /* ARP request for our address? */
      if (for_us) {
        /* send ARP response */
        etharp_raw(netif,
                   (struct eth_addr *)netif->hwaddr, &hdr->shwaddr,
                   (struct eth_addr *)netif->hwaddr, netif_ip4_addr(netif),
                   &hdr->shwaddr, &sipaddr,
                   ARP_REPLY);
        /* we are not configured? */
      } else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
[l_716:]
        /* { for_us == 0 and netif->ip_addr.addr == 0 } */  *** should this
really be commented out? ***
        LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: we are
unconfigured, ARP request ignored.\n"));
        /* request was not directed to us */
      } else {
        /* { for_us == 0 and netif->ip_addr.addr != 0 } */
        LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: ARP
request was not for us.\n"));
      }
      break;
...
*****************************************

The line 715 seems to replace the commented line 714 which seems to be
correct for me.
>From the debug log is obvious that the etharp_input will ignore the ARP
request coming form the client because this line 715.
Checking further the code I observed that the "if" part in lines 682 and 715
seems to be identical. Is this a bug or wanted? For me it seems superfluous.

Can anyone comment on this?

Or am doing something wrong?
Any advise what should I do to solve this or what should I further check?

Thank you in advance.
Steve




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html



reply via email to

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