]> granicus.if.org Git - esp-idf/commitdiff
lwip: fix tcp stable test abort issue
authorLiu Zhi Fu <liuzhifu@espressif.com>
Wed, 19 Apr 2017 08:18:07 +0000 (16:18 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Wed, 19 Apr 2017 09:39:32 +0000 (17:39 +0800)
1. Modify dhcp server timer to 1 seconds
2. Enable ETHARP_TRUST_IP_MAC

modify according to review

components/lwip/apps/dhcpserver.c
components/lwip/include/lwip/apps/dhcpserver.h
components/lwip/include/lwip/netif/etharp.h
components/lwip/include/lwip/port/lwipopts.h
components/lwip/netif/etharp.c

index 94acc881e2adb8ac40ce3d19d17d5f2d3d598492..d3cf993709ba28ba59786bdf85a3bb19f098b6a1 100644 (file)
@@ -719,6 +719,8 @@ static u8_t parse_options(u8_t *optptr, s16_t len)
 *******************************************************************************/
 static s16_t parse_msg(struct dhcps_msg *m, u16_t len)
 {
+    u32_t lease_timer = (dhcps_lease_time * 60)/DHCPS_COARSE_TIMER_SECS;
+    
     if (memcmp((char *)m->options, &magic_cookie, sizeof(magic_cookie)) == 0) {
 #if DHCPS_DEBUG
         DHCPS_LOG("dhcps: len = %d\n", len);
@@ -745,7 +747,7 @@ static s16_t parse_msg(struct dhcps_msg *m, u16_t len)
                     }
 
                     client_address.addr = pdhcps_pool->ip.addr;
-                    pdhcps_pool->lease_timer = dhcps_lease_time;
+                    pdhcps_pool->lease_timer = lease_timer;
                     pnode = pback_node;
                     goto POOL_CHECK;
                 } else if (pdhcps_pool->ip.addr == client_address_plus.addr) {
@@ -783,7 +785,7 @@ static s16_t parse_msg(struct dhcps_msg *m, u16_t len)
 
             pdhcps_pool->ip.addr = client_address.addr;
             memcpy(pdhcps_pool->mac, m->chaddr, sizeof(pdhcps_pool->mac));
-            pdhcps_pool->lease_timer = dhcps_lease_time;
+            pdhcps_pool->lease_timer = lease_timer;
             pnode = (list_node *)malloc(sizeof(list_node));
             memset(pnode , 0x00 , sizeof(list_node));
 
index 39781d9666e48c3badc10b49507ce8be36133583..9e361833d3de0dda5c73d67006f5eae8be2b7967 100644 (file)
@@ -166,6 +166,7 @@ enum dhcps_offer_option{
        OFFER_END
 };
 
+#define DHCPS_COARSE_TIMER_SECS  1
 #define DHCPS_MAX_LEASE 0x64
 #define DHCPS_LEASE_TIME_DEF   (120)
 
index e745dcc3ee61ec8f3cae9b7af2891b7ae83e32cf..3e25c389d25ebb9f65c14496351603fd07a5903a 100755 (executable)
@@ -134,6 +134,10 @@ err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
 
 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p);
 
+#if ETHARP_TRUST_IP_MAC
+void etharp_ip_input(struct netif *netif, struct pbuf *p);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 21a5ac4175e0c4be563ce519848d9bc1cd29adaf..b179b17d3ff1c65b2973ac6ff49ea72d388e4f9c 100644 (file)
  */
 #define TCPIP_DEBUG                     LWIP_DBG_OFF
 
+/**
+ * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
+ * updated with the source MAC and IP addresses supplied in the packet.
+ * You may want to disable this if you do not trust LAN peers to have the
+ * correct addresses, or as a limited approach to attempt to handle
+ * spoofing. If disabled, lwIP will need to make a new ARP request if
+ * the peer is not already in the ARP table, adding a little latency.
+ * The peer *is* in the ARP table if it requested our address before.
+ * Also notice that this slows down input processing of every IP packet!
+ */
+#define ETHARP_TRUST_IP_MAC             1
+
 
 /* Enable all Espressif-only options */
 
index b51a20222202865ff5b276c5c3405d4ff15adf4b..d9854dbb0b8ba57996987be730cd3534e4c779d5 100755 (executable)
@@ -670,8 +670,7 @@ etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_a
  *
  * @see pbuf_free()
  */
-static void
-etharp_ip_input(struct netif *netif, struct pbuf *p)
+void etharp_ip_input(struct netif *netif, struct pbuf *p)
 {
   struct eth_hdr *ethhdr;
   struct ip_hdr *iphdr;