Commit d77666c0 authored by sergio's avatar sergio Committed by Terry Ellison
Browse files

trailing spaces cleanup (#2659)

parent d7583040
############################################################# #############################################################
# Required variables for each makefile # Required variables for each makefile
# Discard this section from all parent makefiles # Discard this section from all parent makefiles
# Expected variables (with automatic defaults): # Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir) # CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile) # SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated () # GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated () # GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form # COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into # subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a () # a generated lib/image xxx.a ()
# #
ifndef PDIR ifndef PDIR
GEN_LIBS = liblwipipv4.a GEN_LIBS = liblwipipv4.a
endif endif
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here! # Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the # Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden # makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein # for a subtree within the makefile rooted therein
# #
#DEFINES += #DEFINES +=
############################################################# #############################################################
# Recursion Magic - Don't touch this!! # Recursion Magic - Don't touch this!!
# #
# Each subtree potentially has an include directory # Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules # corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH # rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up # of a module can only contain the include directories up
# its parent path, and not its siblings # its parent path, and not its siblings
# #
# Required for each makefile to inherit from the parent # Required for each makefile to inherit from the parent
# #
INCLUDES := $(INCLUDES) -I $(PDIR)include INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./ INCLUDES += -I ./
PDIR := ../$(PDIR) PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile sinclude $(PDIR)Makefile
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
/******************************************************************************* /*******************************************************************************
* USAGE: * USAGE:
* *
* define LWIP_AUTOIP 1 in your lwipopts.h * define LWIP_AUTOIP 1 in your lwipopts.h
* *
* If you don't use tcpip.c (so, don't call, you don't call tcpip_init): * If you don't use tcpip.c (so, don't call, you don't call tcpip_init):
* - First, call autoip_init(). * - First, call autoip_init().
* - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces, * - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces,
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
* *
* Without DHCP: * Without DHCP:
* - Call autoip_start() after netif_add(). * - Call autoip_start() after netif_add().
* *
* With DHCP: * With DHCP:
* - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h. * - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h.
* - Configure your DHCP Client. * - Configure your DHCP Client.
...@@ -210,7 +210,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) ...@@ -210,7 +210,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr)
u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif));
addr += netif->autoip->tried_llipaddr; addr += netif->autoip->tried_llipaddr;
addr = AUTOIP_NET | (addr & 0xffff); addr = AUTOIP_NET | (addr & 0xffff);
/* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */
if (addr < AUTOIP_RANGE_START) { if (addr < AUTOIP_RANGE_START) {
addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
...@@ -221,7 +221,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) ...@@ -221,7 +221,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr)
LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) && LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) &&
(addr <= AUTOIP_RANGE_END)); (addr <= AUTOIP_RANGE_END));
ip4_addr_set_u32(ipaddr, htonl(addr)); ip4_addr_set_u32(ipaddr, htonl(addr));
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
(u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), (u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr),
...@@ -276,7 +276,7 @@ autoip_bind(struct netif *netif) ...@@ -276,7 +276,7 @@ autoip_bind(struct netif *netif)
netif_set_ipaddr(netif, &autoip->llipaddr); netif_set_ipaddr(netif, &autoip->llipaddr);
netif_set_netmask(netif, &sn_mask); netif_set_netmask(netif, &sn_mask);
netif_set_gw(netif, &gw_addr); netif_set_gw(netif, &gw_addr);
/* bring the interface up */ /* bring the interface up */
netif_set_up(netif); netif_set_up(netif);
...@@ -501,7 +501,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) ...@@ -501,7 +501,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
*/ */
IPADDR2_COPY(&sipaddr, &hdr->sipaddr); IPADDR2_COPY(&sipaddr, &hdr->sipaddr);
IPADDR2_COPY(&dipaddr, &hdr->dipaddr); IPADDR2_COPY(&dipaddr, &hdr->dipaddr);
if ((netif->autoip->state == AUTOIP_STATE_PROBING) || if ((netif->autoip->state == AUTOIP_STATE_PROBING) ||
((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) && ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) &&
(netif->autoip->sent_num == 0))) { (netif->autoip->sent_num == 0))) {
......
...@@ -104,7 +104,7 @@ icmp_input(struct pbuf *p, struct netif *inp) ...@@ -104,7 +104,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
case ICMP_ER: case ICMP_ER:
/* This is OK, echo reply might have been parsed by a raw PCB /* This is OK, echo reply might have been parsed by a raw PCB
(as obviously, an echo request has been sent, too). */ (as obviously, an echo request has been sent, too). */
break; break;
case ICMP_ECHO: case ICMP_ECHO:
#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING #if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
{ {
...@@ -224,7 +224,7 @@ icmp_input(struct pbuf *p, struct netif *inp) ...@@ -224,7 +224,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
} }
break; break;
default: default:
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n",
(s16_t)type, (s16_t)code)); (s16_t)type, (s16_t)code));
ICMP_STATS_INC(icmp.proterr); ICMP_STATS_INC(icmp.proterr);
ICMP_STATS_INC(icmp.drop); ICMP_STATS_INC(icmp.drop);
......
...@@ -8,29 +8,29 @@ ...@@ -8,29 +8,29 @@
* Copyright (c) 2002 CITEL Technologies Ltd. * Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is a contribution to the lwIP TCP/IP stack. * This file is a contribution to the lwIP TCP/IP stack.
* The Swedish Institute of Computer Science and Adam Dunkels * The Swedish Institute of Computer Science and Adam Dunkels
...@@ -70,7 +70,7 @@ Steve Reynolds ...@@ -70,7 +70,7 @@ Steve Reynolds
* RFC 2236 - Internet Group Management Protocol, Version 2 - V2 <- this code is based on this RFC (it's the "de facto" standard) * RFC 2236 - Internet Group Management Protocol, Version 2 - V2 <- this code is based on this RFC (it's the "de facto" standard)
* RFC 3376 - Internet Group Management Protocol, Version 3 - V3 * RFC 3376 - Internet Group Management Protocol, Version 3 - V3
* RFC 4604 - Using Internet Group Management Protocol Version 3... - V3+ * RFC 4604 - Using Internet Group Management Protocol Version 3... - V3+
* RFC 2113 - IP Router Alert Option - * RFC 2113 - IP Router Alert Option -
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
...@@ -106,7 +106,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__; ...@@ -106,7 +106,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__;
#define IGMP_LOG //os_printf #define IGMP_LOG //os_printf
#endif #endif
/* /*
* IGMP constants * IGMP constants
*/ */
#define IGMP_TTL 1 #define IGMP_TTL 1
...@@ -180,18 +180,18 @@ igmp_init(void) ...@@ -180,18 +180,18 @@ igmp_init(void)
*/ */
void void
igmp_dump_group_list() igmp_dump_group_list()
{ {
struct igmp_group *group = igmp_group_list; struct igmp_group *group = igmp_group_list;
IGMP_LOG("igmp_dump:\n"); IGMP_LOG("igmp_dump:\n");
while (group != NULL) { while (group != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_dump_group_list: [%"U32_F"] ", (u32_t)(group->group_state))); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_dump_group_list: [%"U32_F"] ", (u32_t)(group->group_state)));
ip_addr_debug_print(IGMP_DEBUG, &group->group_address); ip_addr_debug_print(IGMP_DEBUG, &group->group_address);
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif));
if(group!=NULL) if(group!=NULL)
IGMP_LOG("group:%p,netif:%p\n",group,group->netif); IGMP_LOG("group:%p,netif:%p\n",group,group->netif);
group = group->next; group = group->next;
} }
LWIP_DEBUGF(IGMP_DEBUG, ("\n")); LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
...@@ -341,7 +341,7 @@ struct igmp_group * ...@@ -341,7 +341,7 @@ struct igmp_group *
igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) igmp_lookup_group(struct netif *ifp, ip_addr_t *addr)
{ {
struct igmp_group *group = igmp_group_list; struct igmp_group *group = igmp_group_list;
/* Search if the group already exists */ /* Search if the group already exists */
group = igmp_lookfor_group(ifp, addr); group = igmp_lookfor_group(ifp, addr);
if (group != NULL) { if (group != NULL) {
...@@ -421,7 +421,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) ...@@ -421,7 +421,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)
IGMP_STATS_INC(igmp.recv); IGMP_STATS_INC(igmp.recv);
/* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */
iphdr = (struct ip_hdr *)p->payload; iphdr = (struct ip_hdr *)p->payload;
if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) { if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) {
pbuf_free(p); pbuf_free(p);
...@@ -447,7 +447,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) ...@@ -447,7 +447,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)
/* Packet is ok so find an existing group */ /* Packet is ok so find an existing group */
group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */ group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */
/* If group can be found or create... */ /* If group can be found or create... */
if (!group) { if (!group) {
pbuf_free(p); pbuf_free(p);
...@@ -640,7 +640,7 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) ...@@ -640,7 +640,7 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)
IGMP_STATS_INC(igmp.tx_leave); IGMP_STATS_INC(igmp.tx_leave);
igmp_send(group, IGMP_LEAVE_GROUP); igmp_send(group, IGMP_LEAVE_GROUP);
} }
/* Disable the group at the MAC level */ /* Disable the group at the MAC level */
if (netif->igmp_mac_filter != NULL) { if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL "));
...@@ -648,11 +648,11 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) ...@@ -648,11 +648,11 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER); netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER);
} }
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: "));
ip_addr_debug_print(IGMP_DEBUG, groupaddr); ip_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, ("\n")); LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
/* Free the group */ /* Free the group */
igmp_remove_group(group); igmp_remove_group(group);
} else { } else {
...@@ -808,13 +808,13 @@ igmp_send(struct igmp_group *group, u8_t type) ...@@ -808,13 +808,13 @@ igmp_send(struct igmp_group *group, u8_t type)
/* IP header + "router alert" option + IGMP header */ /* IP header + "router alert" option + IGMP header */
p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM); p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM);
if (p) { if (p) {
igmp = (struct igmp_msg *)p->payload; igmp = (struct igmp_msg *)p->payload;
LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg", LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
(p->len >= sizeof(struct igmp_msg))); (p->len >= sizeof(struct igmp_msg)));
ip_addr_copy(src, group->netif->ip_addr); ip_addr_copy(src, group->netif->ip_addr);
if (type == IGMP_V2_MEMB_REPORT) { if (type == IGMP_V2_MEMB_REPORT) {
dest = &(group->group_address); dest = &(group->group_address);
ip_addr_copy(igmp->igmp_group_address, group->group_address); ip_addr_copy(igmp->igmp_group_address, group->group_address);
......
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
* aim of being simple, correct and fully portable. Checksumming is the * aim of being simple, correct and fully portable. Checksumming is the
* first thing you would want to optimize for your platform. If you create * first thing you would want to optimize for your platform. If you create
* your own version, link it in and in your cc.h put: * your own version, link it in and in your cc.h put:
* *
* #define LWIP_CHKSUM <your_checksum_routine> * #define LWIP_CHKSUM <your_checksum_routine>
* *
* Or you can select from the implementations below by defining * Or you can select from the implementations below by defining
* LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3.
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
* *
* @param dataptr points to start of data to be summed at any boundary * @param dataptr points to start of data to be summed at any boundary
* @param len length of data to be summed * @param len length of data to be summed
* @return host order (!) lwip checksum (non-inverted Internet sum) * @return host order (!) lwip checksum (non-inverted Internet sum)
* *
* @note accumulator size limits summable length to 64k * @note accumulator size limits summable length to 64k
* @note host endianess is irrelevant (p3 RFC1071) * @note host endianess is irrelevant (p3 RFC1071)
...@@ -128,7 +128,7 @@ lwip_standard_chksum(void *dataptr, u16_t len) ...@@ -128,7 +128,7 @@ lwip_standard_chksum(void *dataptr, u16_t len)
* *
* @param dataptr points to start of data to be summed at any boundary * @param dataptr points to start of data to be summed at any boundary
* @param len length of data to be summed * @param len length of data to be summed
* @return host order (!) lwip checksum (non-inverted Internet sum) * @return host order (!) lwip checksum (non-inverted Internet sum)
*/ */
static u16_t ICACHE_FLASH_ATTR static u16_t ICACHE_FLASH_ATTR
...@@ -178,12 +178,12 @@ lwip_standard_chksum(void *dataptr, int len) ...@@ -178,12 +178,12 @@ lwip_standard_chksum(void *dataptr, int len)
/** /**
* An optimized checksum routine. Basically, it uses loop-unrolling on * An optimized checksum routine. Basically, it uses loop-unrolling on
* the checksum loop, treating the head and tail bytes specially, whereas * the checksum loop, treating the head and tail bytes specially, whereas
* the inner loop acts on 8 bytes at a time. * the inner loop acts on 8 bytes at a time.
* *
* @arg start of buffer to be checksummed. May be an odd byte address. * @arg start of buffer to be checksummed. May be an odd byte address.
* @len number of bytes in the buffer to be checksummed. * @len number of bytes in the buffer to be checksummed.
* @return host order (!) lwip checksum (non-inverted Internet sum) * @return host order (!) lwip checksum (non-inverted Internet sum)
* *
* by Curt McDowell, Broadcom Corp. December 8th, 2005 * by Curt McDowell, Broadcom Corp. December 8th, 2005
*/ */
......
/** /**
* @file * @file
* This is the IPv4 layer implementation for incoming and outgoing IP traffic. * This is the IPv4 layer implementation for incoming and outgoing IP traffic.
* *
* @see ip_frag.c * @see ip_frag.c
* *
*/ */
...@@ -171,7 +171,7 @@ ip_router(ip_addr_t *dest, ip_addr_t *source){ ...@@ -171,7 +171,7 @@ ip_router(ip_addr_t *dest, ip_addr_t *source){
/* iterate through netifs */ /* iterate through netifs */
for(netif = netif_list; netif != NULL; netif = netif->next) { for(netif = netif_list; netif != NULL; netif = netif->next) {
/* network mask matches? */ /* network mask matches? */
if (netif_is_up(netif)) { if (netif_is_up(netif)) {
if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
/* return netif on which to forward IP packet */ /* return netif on which to forward IP packet */
...@@ -285,7 +285,7 @@ return_noroute: ...@@ -285,7 +285,7 @@ return_noroute:
* forwarded (using ip_forward). The IP checksum is always checked. * forwarded (using ip_forward). The IP checksum is always checked.
* *
* Finally, the packet is sent to the upper layer protocol input function. * Finally, the packet is sent to the upper layer protocol input function.
* *
* @param p the received IP packet (p->payload points to IP header) * @param p the received IP packet (p->payload points to IP header)
* @param inp the netif on which this packet was received * @param inp the netif on which this packet was received
* @return ERR_OK if the packet was processed (could return ERR_* if it wasn't * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
...@@ -45,8 +45,8 @@ const ip_addr_t ip_addr_any ICACHE_RODATA_ATTR = { IPADDR_ANY }; ...@@ -45,8 +45,8 @@ const ip_addr_t ip_addr_any ICACHE_RODATA_ATTR = { IPADDR_ANY };
const ip_addr_t ip_addr_broadcast ICACHE_RODATA_ATTR = { IPADDR_BROADCAST }; const ip_addr_t ip_addr_broadcast ICACHE_RODATA_ATTR = { IPADDR_BROADCAST };
/** /**
* Determine if an address is a broadcast address on a network interface * Determine if an address is a broadcast address on a network interface
* *
* @param addr address to be checked * @param addr address to be checked
* @param netif the network interface against which the address is checked * @param netif the network interface against which the address is checked
* @return returns non-zero if the address is a broadcast address * @return returns non-zero if the address is a broadcast address
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
...@@ -17,25 +17,25 @@ ...@@ -17,25 +17,25 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Jani Monoses <jani@iv.ro> * Author: Jani Monoses <jani@iv.ro>
* Simon Goldschmidt * Simon Goldschmidt
* original reassembly code by Adam Dunkels <adam@sics.se> * original reassembly code by Adam Dunkels <adam@sics.se>
* *
*/ */
#include "lwip/opt.h" #include "lwip/opt.h"
...@@ -185,7 +185,7 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p ...@@ -185,7 +185,7 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
} }
#endif /* LWIP_ICMP */ #endif /* LWIP_ICMP */
/* First, free all received pbufs. The individual pbufs need to be released /* First, free all received pbufs. The individual pbufs need to be released
separately as they have not yet been chained */ separately as they have not yet been chained */
p = ipr->p; p = ipr->p;
while (p != NULL) { while (p != NULL) {
...@@ -303,7 +303,7 @@ ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) ...@@ -303,7 +303,7 @@ ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen)
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev)
{ {
/* dequeue the reass struct */ /* dequeue the reass struct */
if (reassdatagrams == ipr) { if (reassdatagrams == ipr) {
/* it was the first in the list */ /* it was the first in the list */
...@@ -337,7 +337,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct ...@@ -337,7 +337,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
int valid = 1; int valid = 1;
/* Extract length and fragment offset from current fragment */ /* Extract length and fragment offset from current fragment */
fraghdr = (struct ip_hdr*)new_p->payload; fraghdr = (struct ip_hdr*)new_p->payload;
len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4;
offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8;
...@@ -538,7 +538,7 @@ ip_reass(struct pbuf *p) ...@@ -538,7 +538,7 @@ ip_reass(struct pbuf *p)
goto nullreturn; goto nullreturn;
} }
} else { } else {
if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) &&
((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) {
/* ipr->iphdr is not the header from the first fragment, but fraghdr is /* ipr->iphdr is not the header from the first fragment, but fraghdr is
* -> copy fraghdr into ipr->iphdr since we want to have the header * -> copy fraghdr into ipr->iphdr since we want to have the header
...@@ -547,11 +547,11 @@ ip_reass(struct pbuf *p) ...@@ -547,11 +547,11 @@ ip_reass(struct pbuf *p)
SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN); SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN);
} }
} }
/* Track the current number of pbufs current 'in-flight', in order to limit /* Track the current number of pbufs current 'in-flight', in order to limit
the number of fragments that may be enqueued at any one time */ the number of fragments that may be enqueued at any one time */
ip_reass_pbufcount += clen; ip_reass_pbufcount += clen;
/* At this point, we have either created a new entry or pointing /* At this point, we have either created a new entry or pointing
* to an existing one */ * to an existing one */
/* check for 'no more fragments', and update queue entry*/ /* check for 'no more fragments', and update queue entry*/
...@@ -663,7 +663,7 @@ ipfrag_free_pbuf_custom(struct pbuf *p) ...@@ -663,7 +663,7 @@ ipfrag_free_pbuf_custom(struct pbuf *p)
* *
* @return ERR_OK if sent successfully, err_t otherwise * @return ERR_OK if sent successfully, err_t otherwise
*/ */
err_t err_t
ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
{ {
struct pbuf *rambuf; struct pbuf *rambuf;
...@@ -818,8 +818,8 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) ...@@ -818,8 +818,8 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
pbuf_realloc(rambuf, left + IP_HLEN); pbuf_realloc(rambuf, left + IP_HLEN);
} }
/* This part is ugly: we alloc a RAM based pbuf for /* This part is ugly: we alloc a RAM based pbuf for
* the link level header for each chunk and then * the link level header for each chunk and then
* free it.A PBUF_ROM style pbuf for which pbuf_header * free it.A PBUF_ROM style pbuf for which pbuf_header
* worked would make things simpler. * worked would make things simpler.
*/ */
...@@ -848,7 +848,7 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) ...@@ -848,7 +848,7 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
* will have already sent the packet, the free will really free, and * will have already sent the packet, the free will really free, and
* there will be zero memory penalty. * there will be zero memory penalty.
*/ */
pbuf_free(rambuf); pbuf_free(rambuf);
#endif /* IP_FRAG_USES_STATIC_BUF */ #endif /* IP_FRAG_USES_STATIC_BUF */
left -= cop; left -= cop;
......
...@@ -470,7 +470,7 @@ mem_trim(void *rmem, mem_size_t newsize) ...@@ -470,7 +470,7 @@ mem_trim(void *rmem, mem_size_t newsize)
/* else { /* else {
next struct mem is used but size between mem and mem2 is not big enough next struct mem is used but size between mem and mem2 is not big enough
to create another struct mem to create another struct mem
-> don't do anyhting. -> don't do anyhting.
-> the remaining space stays unused since it is too small -> the remaining space stays unused since it is too small
} */ } */
#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
...@@ -19,21 +19,21 @@ ...@@ -19,21 +19,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
...@@ -158,19 +158,19 @@ const char *memp_desc[MEMP_MAX] = { ...@@ -158,19 +158,19 @@ const char *memp_desc[MEMP_MAX] = {
* extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[];
*/ */
#define LWIP_MEMPOOL(name,num,size,desc,attr) u8_t memp_memory_ ## name ## _base \ #define LWIP_MEMPOOL(name,num,size,desc,attr) u8_t memp_memory_ ## name ## _base \
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] attr; [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] attr;
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
/** This array holds the base of each memory pool. */ /** This array holds the base of each memory pool. */
static u8_t *const memp_bases[] = { static u8_t *const memp_bases[] = {
#define LWIP_MEMPOOL(name,num,size,desc,attr) memp_memory_ ## name ## _base, #define LWIP_MEMPOOL(name,num,size,desc,attr) memp_memory_ ## name ## _base,
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
}; };
#else /* MEMP_SEPARATE_POOLS */ #else /* MEMP_SEPARATE_POOLS */
/** This is the actual memory used by the pools (all pools in one big block). */ /** This is the actual memory used by the pools (all pools in one big block). */
static u8_t memp_memory[MEM_ALIGNMENT - 1 static u8_t memp_memory[MEM_ALIGNMENT - 1
#define LWIP_MEMPOOL(name,num,size,desc, attr) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #define LWIP_MEMPOOL(name,num,size,desc, attr) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
]; ];
...@@ -334,7 +334,7 @@ memp_overflow_init(void) ...@@ -334,7 +334,7 @@ memp_overflow_init(void)
/** /**
* Initialize this module. * Initialize this module.
* *
* Carves out memp_memory into linked lists for each pool-type. * Carves out memp_memory into linked lists for each pool-type.
*/ */
void void
...@@ -397,7 +397,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) ...@@ -397,7 +397,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
{ {
struct memp *memp; struct memp *memp;
SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_DECL_PROTECT(old_level);
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
SYS_ARCH_PROTECT(old_level); SYS_ARCH_PROTECT(old_level);
...@@ -406,7 +406,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) ...@@ -406,7 +406,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK >= 2 */
memp = memp_tab[type]; memp = memp_tab[type];
if (memp != NULL) { if (memp != NULL) {
memp_tab[type] = memp->next; memp_tab[type] = memp->next;
#if MEMP_OVERFLOW_CHECK #if MEMP_OVERFLOW_CHECK
...@@ -458,9 +458,9 @@ memp_free(memp_t type, void *mem) ...@@ -458,9 +458,9 @@ memp_free(memp_t type, void *mem)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK >= 2 */
#endif /* MEMP_OVERFLOW_CHECK */ #endif /* MEMP_OVERFLOW_CHECK */
MEMP_STATS_DEC(used, type); MEMP_STATS_DEC(used, type);
memp->next = memp_tab[type]; memp->next = memp_tab[type];
memp_tab[type] = memp; memp_tab[type] = memp;
#if MEMP_SANITY_CHECK #if MEMP_SANITY_CHECK
......
...@@ -64,13 +64,13 @@ ...@@ -64,13 +64,13 @@
#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) #define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
#else #else
#define NETIF_STATUS_CALLBACK(n) #define NETIF_STATUS_CALLBACK(n)
#endif /* LWIP_NETIF_STATUS_CALLBACK */ #endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK #if LWIP_NETIF_LINK_CALLBACK
#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0) #define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0)
#else #else
#define NETIF_LINK_CALLBACK(n) #define NETIF_LINK_CALLBACK(n)
#endif /* LWIP_NETIF_LINK_CALLBACK */ #endif /* LWIP_NETIF_LINK_CALLBACK */
struct netif *netif_list; struct netif *netif_list;
struct netif *netif_default; struct netif *netif_default;
...@@ -441,17 +441,17 @@ netif_set_default(struct netif *netif) ...@@ -441,17 +441,17 @@ netif_set_default(struct netif *netif)
/** /**
* Bring an interface up, available for processing * Bring an interface up, available for processing
* traffic. * traffic.
* *
* @note: Enabling DHCP on a down interface will make it come * @note: Enabling DHCP on a down interface will make it come
* up once configured. * up once configured.
* *
* @see dhcp_start() * @see dhcp_start()
*/ */
void netif_set_up(struct netif *netif) void netif_set_up(struct netif *netif)
{ {
if (!(netif->flags & NETIF_FLAG_UP)) { if (!(netif->flags & NETIF_FLAG_UP)) {
netif->flags |= NETIF_FLAG_UP; netif->flags |= NETIF_FLAG_UP;
#if LWIP_SNMP #if LWIP_SNMP
snmp_get_sysuptime(&netif->ts); snmp_get_sysuptime(&netif->ts);
#endif /* LWIP_SNMP */ #endif /* LWIP_SNMP */
...@@ -460,7 +460,7 @@ void netif_set_up(struct netif *netif) ...@@ -460,7 +460,7 @@ void netif_set_up(struct netif *netif)
if (netif->flags & NETIF_FLAG_LINK_UP) { if (netif->flags & NETIF_FLAG_LINK_UP) {
#if LWIP_ARP #if LWIP_ARP
/* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
if (netif->flags & (NETIF_FLAG_ETHARP)) { if (netif->flags & (NETIF_FLAG_ETHARP)) {
etharp_gratuitous(netif); etharp_gratuitous(netif);
} }
...@@ -481,12 +481,12 @@ void netif_set_up(struct netif *netif) ...@@ -481,12 +481,12 @@ void netif_set_up(struct netif *netif)
* *
* @note: Enabling DHCP on a down interface will make it come * @note: Enabling DHCP on a down interface will make it come
* up once configured. * up once configured.
* *
* @see dhcp_start() * @see dhcp_start()
*/ */
void netif_set_down(struct netif *netif) void netif_set_down(struct netif *netif)
{ {
if (netif == NULL) { if (netif == NULL) {
return; return;
} }
...@@ -539,7 +539,7 @@ void netif_set_link_up(struct netif *netif ) ...@@ -539,7 +539,7 @@ void netif_set_link_up(struct netif *netif )
if (netif->flags & NETIF_FLAG_UP) { if (netif->flags & NETIF_FLAG_UP) {
#if LWIP_ARP #if LWIP_ARP
/* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
if (netif->flags & NETIF_FLAG_ETHARP) { if (netif->flags & NETIF_FLAG_ETHARP) {
etharp_gratuitous(netif); etharp_gratuitous(netif);
} }
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
* *
* Multiple packets may be queued, also using this singly linked list. * Multiple packets may be queued, also using this singly linked list.
* This is called a "packet queue". * This is called a "packet queue".
* *
* So, a packet queue consists of one or more pbuf chains, each of * So, a packet queue consists of one or more pbuf chains, each of
* which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE * which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE
* NOT SUPPORTED!!! Use helper structs to queue multiple packets. * NOT SUPPORTED!!! Use helper structs to queue multiple packets.
* *
* The differences between a pbuf chain and a packet queue are very * The differences between a pbuf chain and a packet queue are very
* precise but subtle. * precise but subtle.
* *
* The last pbuf of a packet has a ->tot_len field that equals the * The last pbuf of a packet has a ->tot_len field that equals the
* ->len field. It can be found by traversing the list. If the last * ->len field. It can be found by traversing the list. If the last
...@@ -580,7 +580,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) ...@@ -580,7 +580,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
if ((header_size_increment == 0) || (p == NULL)) { if ((header_size_increment == 0) || (p == NULL)) {
return 0; return 0;
} }
if (header_size_increment < 0){ if (header_size_increment < 0){
increment_magnitude = -header_size_increment; increment_magnitude = -header_size_increment;
/* Check that we aren't going to move off the end of the pbuf */ /* Check that we aren't going to move off the end of the pbuf */
...@@ -591,7 +591,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) ...@@ -591,7 +591,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
/* Can't assert these as some callers speculatively call /* Can't assert these as some callers speculatively call
pbuf_header() to see if it's OK. Will return 1 below instead. */ pbuf_header() to see if it's OK. Will return 1 below instead. */
/* Check that we've got the correct type of pbuf to work with */ /* Check that we've got the correct type of pbuf to work with */
LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL",
p->type == PBUF_RAM || p->type == PBUF_POOL); p->type == PBUF_RAM || p->type == PBUF_POOL);
/* Check that we aren't going to move off the beginning of the pbuf */ /* Check that we aren't going to move off the beginning of the pbuf */
LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF", LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF",
...@@ -673,7 +673,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) ...@@ -673,7 +673,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
* *
* Assuming existing chains a->b->c with the following reference * Assuming existing chains a->b->c with the following reference
* counts, calling pbuf_free(a) results in: * counts, calling pbuf_free(a) results in:
* *
* 1->2->3 becomes ...1->3 * 1->2->3 becomes ...1->3
* 3->3->3 becomes 2->3->3 * 3->3->3 becomes 2->3->3
* 1->1->2 becomes ......1 * 1->1->2 becomes ......1
...@@ -701,7 +701,7 @@ pbuf_free(struct pbuf *p) ...@@ -701,7 +701,7 @@ pbuf_free(struct pbuf *p)
LWIP_ASSERT("pbuf_free: sane type", LWIP_ASSERT("pbuf_free: sane type",
p->type == PBUF_RAM || p->type == PBUF_ROM || p->type == PBUF_RAM || p->type == PBUF_ROM ||
p->type == PBUF_REF || p->type == PBUF_POOL p->type == PBUF_REF || p->type == PBUF_POOL
#ifdef EBUF_LWIP #ifdef EBUF_LWIP
|| p->type == PBUF_ESF_RX || p->type == PBUF_ESF_RX
#endif //EBUF_LWIP #endif //EBUF_LWIP
...@@ -812,10 +812,10 @@ pbuf_ref(struct pbuf *p) ...@@ -812,10 +812,10 @@ pbuf_ref(struct pbuf *p)
/** /**
* Concatenate two pbufs (each may be a pbuf chain) and take over * Concatenate two pbufs (each may be a pbuf chain) and take over
* the caller's reference of the tail pbuf. * the caller's reference of the tail pbuf.
* *
* @note The caller MAY NOT reference the tail pbuf afterwards. * @note The caller MAY NOT reference the tail pbuf afterwards.
* Use pbuf_chain() for that purpose. * Use pbuf_chain() for that purpose.
* *
* @see pbuf_chain() * @see pbuf_chain()
*/ */
...@@ -846,10 +846,10 @@ pbuf_cat(struct pbuf *h, struct pbuf *t) ...@@ -846,10 +846,10 @@ pbuf_cat(struct pbuf *h, struct pbuf *t)
/** /**
* Chain two pbufs (or pbuf chains) together. * Chain two pbufs (or pbuf chains) together.
* *
* The caller MUST call pbuf_free(t) once it has stopped * The caller MUST call pbuf_free(t) once it has stopped
* using it. Use pbuf_cat() instead if you no longer use t. * using it. Use pbuf_cat() instead if you no longer use t.
* *
* @param h head pbuf (chain) * @param h head pbuf (chain)
* @param t tail pbuf (chain) * @param t tail pbuf (chain)
* @note The pbufs MUST belong to the same packet. * @note The pbufs MUST belong to the same packet.
...@@ -987,7 +987,7 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) ...@@ -987,7 +987,7 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
* *
* @param buf the pbuf from which to copy data * @param buf the pbuf from which to copy data
* @param dataptr the application supplied buffer * @param dataptr the application supplied buffer
* @param len length of data to copy (dataptr must be big enough). No more * @param len length of data to copy (dataptr must be big enough). No more
* than buf->tot_len will be copied, irrespective of len * than buf->tot_len will be copied, irrespective of len
* @param offset offset into the packet buffer from where to begin copying len bytes * @param offset offset into the packet buffer from where to begin copying len bytes
* @return the number of bytes copied, or 0 on failure * @return the number of bytes copied, or 0 on failure
......
...@@ -172,14 +172,14 @@ raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr) ...@@ -172,14 +172,14 @@ raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
/** /**
* Set the callback function for received packets that match the * Set the callback function for received packets that match the
* raw PCB's protocol and binding. * raw PCB's protocol and binding.
* *
* The callback function MUST either * The callback function MUST either
* - eat the packet by calling pbuf_free() and returning non-zero. The * - eat the packet by calling pbuf_free() and returning non-zero. The
* packet will not be passed to other raw PCBs or other protocol layers. * packet will not be passed to other raw PCBs or other protocol layers.
* - not free the packet, and return zero. The packet will be matched * - not free the packet, and return zero. The packet will be matched
* against further PCBs and/or forwarded to another protocol layers. * against further PCBs and/or forwarded to another protocol layers.
* *
* @return non-zero if the packet was free()d, zero if the packet remains * @return non-zero if the packet was free()d, zero if the packet remains
* available for others. * available for others.
*/ */
...@@ -210,9 +210,9 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr) ...@@ -210,9 +210,9 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
struct netif *netif; struct netif *netif;
ip_addr_t *src_ip; ip_addr_t *src_ip;
struct pbuf *q; /* q will be sent down the stack */ struct pbuf *q; /* q will be sent down the stack */
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n")); LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n"));
/* not enough space to add an IP header to first pbuf in given p chain? */ /* not enough space to add an IP header to first pbuf in given p chain? */
if (pbuf_header(p, IP_HLEN)) { if (pbuf_header(p, IP_HLEN)) {
/* allocate header in new pbuf */ /* allocate header in new pbuf */
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
...@@ -72,18 +72,18 @@ void ...@@ -72,18 +72,18 @@ void
stats_display_proto(struct stats_proto *proto, char *name) stats_display_proto(struct stats_proto *proto, char *name)
{ {
LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
} }
#if IGMP_STATS #if IGMP_STATS
...@@ -91,20 +91,20 @@ void ...@@ -91,20 +91,20 @@ void
stats_display_igmp(struct stats_igmp *igmp) stats_display_igmp(struct stats_igmp *igmp)
{ {
LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit));
LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv));
LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop));
LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr));
LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr));
LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1));
LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group)); LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group));
LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general)); LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general));
LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report));
LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join));
LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
} }
#endif /* IGMP_STATS */ #endif /* IGMP_STATS */
...@@ -113,9 +113,9 @@ void ...@@ -113,9 +113,9 @@ void
stats_display_mem(struct stats_mem *mem, char *name) stats_display_mem(struct stats_mem *mem, char *name)
{ {
LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
} }
...@@ -139,15 +139,15 @@ void ...@@ -139,15 +139,15 @@ void
stats_display_sys(struct stats_sys *sys) stats_display_sys(struct stats_sys *sys)
{ {
LWIP_PLATFORM_DIAG(("\nSYS\n\t")); LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used));
LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max));
LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err));
LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
} }
#endif /* SYS_STATS */ #endif /* SYS_STATS */
......
/* /*
* copyright (c) 2010 - 2011 espressif system * copyright (c) 2010 - 2011 espressif system
*/ */
#include "c_types.h" #include "c_types.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "osapi.h" #include "osapi.h"
#include "os_type.h" #include "os_type.h"
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/sys.h" #include "lwip/sys.h"
#include "eagle_soc.h" #include "eagle_soc.h"
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
...@@ -21,21 +21,21 @@ ...@@ -21,21 +21,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
...@@ -61,17 +61,17 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__; ...@@ -61,17 +61,17 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__;
#if TCP_DEBUG #if TCP_DEBUG
const char tcp_state_str_rodata[][12] ICACHE_RODATA_ATTR = { const char tcp_state_str_rodata[][12] ICACHE_RODATA_ATTR = {
"CLOSED", "CLOSED",
"LISTEN", "LISTEN",
"SYN_SENT", "SYN_SENT",
"SYN_RCVD", "SYN_RCVD",
"ESTABLISHED", "ESTABLISHED",
"FIN_WAIT_1", "FIN_WAIT_1",
"FIN_WAIT_2", "FIN_WAIT_2",
"CLOSE_WAIT", "CLOSE_WAIT",
"CLOSING", "CLOSING",
"LAST_ACK", "LAST_ACK",
"TIME_WAIT" "TIME_WAIT"
}; };
char tcp_state_str[12]; char tcp_state_str[12];
...@@ -105,7 +105,7 @@ struct tcp_pcb ** const tcp_pcb_lists[] ICACHE_RODATA_ATTR = {&tcp_listen_pcbs.p ...@@ -105,7 +105,7 @@ struct tcp_pcb ** const tcp_pcb_lists[] ICACHE_RODATA_ATTR = {&tcp_listen_pcbs.p
/** Only used for temporary storage. */ /** Only used for temporary storage. */
struct tcp_pcb *tcp_tmp_pcb; struct tcp_pcb *tcp_tmp_pcb;
/** Timer counter to handle calling slow-timer from tcp_tmr() */ /** Timer counter to handle calling slow-timer from tcp_tmr() */
static u8_t tcp_timer; static u8_t tcp_timer;
static u16_t tcp_new_port(void);//����µ�tcp���ض˿� static u16_t tcp_new_port(void);//����µ�tcp���ض˿�
...@@ -177,24 +177,24 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) ...@@ -177,24 +177,24 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
* however, it is in this state once allocated and as yet unused * however, it is in this state once allocated and as yet unused
* and the user needs some way to free it should the need arise. * and the user needs some way to free it should the need arise.
* Calling tcp_close() with a pcb that has already been closed, (i.e. twice) * Calling tcp_close() with a pcb that has already been closed, (i.e. twice)
* or for a pcb that has been used and then entered the CLOSED state * or for a pcb that has been used and then entered the CLOSED state
* is erroneous, but this should never happen as the pcb has in those cases * is erroneous, but this should never happen as the pcb has in those cases
* been freed, and so any remaining handles are bogus. */ * been freed, and so any remaining handles are bogus. */
/*��CLOSED״̬�¹ر�һ��pcb�ƺ��Ǵ���ģ� /*��CLOSED״̬�¹ر�һ��pcb�ƺ��Ǵ���ģ�
*������ˣ�һ�������״̬�·����˶��һ�û��ʹ��,�û���ҪһЩ�취���ͷ��� *������ˣ�һ�������״̬�·����˶��һ�û��ʹ��,�û���ҪһЩ�취���ͷ���
*����һ���Ѿ����رյ�pcb��tcp_close(),(��2��)����һ���Ѿ���ʹ����֮�󣬽���CLOSE״̬�Ǵ���� *����һ���Ѿ����رյ�pcb��tcp_close(),(��2��)����һ���Ѿ���ʹ����֮�󣬽���CLOSE״̬�Ǵ����
*������Щ����±��ͷŵ�pcb�Dz�����ڵ�,��ˣ��κ�ʣ��ľ���Ǽٵ� *������Щ����±��ͷŵ�pcb�Dz�����ڵ�,��ˣ��κ�ʣ��ľ���Ǽٵ�
*/ */
err = ERR_OK;//�趨����ֵ err = ERR_OK;//�趨����ֵ
if (pcb->local_port != 0) { if (pcb->local_port != 0) {
TCP_RMV(&tcp_bound_pcbs, pcb); TCP_RMV(&tcp_bound_pcbs, pcb);
} }
memp_free(MEMP_TCP_PCB, pcb);//��MEMP_TCP_PCB�ڴ���趨�ͷŵ���pcb��Ӧ�ĵ�Ԫֵ,�ͷ��ڴ� memp_free(MEMP_TCP_PCB, pcb);//��MEMP_TCP_PCB�ڴ���趨�ͷŵ���pcb��Ӧ�ĵ�Ԫֵ,�ͷ��ڴ�
pcb = NULL; pcb = NULL;
break; break;
case LISTEN: case LISTEN:
err = ERR_OK; err = ERR_OK;
tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb);//�Ӽ����PCB�б���ɾ���Ӧ��pcb tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb);//�Ӽ����PCB�б���ɾ���Ӧ��pcb
memp_free(MEMP_TCP_PCB_LISTEN, pcb);//��MEMP_TCP_PCB_LISTEN�ڴ�����趨�ͷŵ�pcb��Ԫֵ ,�ͷ��ڴ� memp_free(MEMP_TCP_PCB_LISTEN, pcb);//��MEMP_TCP_PCB_LISTEN�ڴ�����趨�ͷŵ�pcb��Ԫֵ ,�ͷ��ڴ�
pcb = NULL; pcb = NULL;
break; break;
...@@ -261,14 +261,14 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) ...@@ -261,14 +261,14 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
* @return ERR_OK if connection has been closed * @return ERR_OK if connection has been closed
* another err_t if closing failed and pcb is not freed * another err_t if closing failed and pcb is not freed
*/ */
/* /*
*ͨ��PCB�ر��������� *ͨ��PCB�ر���������
*�����е�pcbӦ�ñ��ͷŵģ�Ҳ����ԶҲ���ᱻʹ���� *�����е�pcbӦ�ñ��ͷŵģ�Ҳ����ԶҲ���ᱻʹ����
*���û�����ӻ�����Ҳû�б�����,���ӵ�pcbӦ�ñ��ͷŵ� *���û�����ӻ�����Ҳû�б�����,���ӵ�pcbӦ�ñ��ͷŵ�
*���һ�����ӱ�����(����SYN�Ѿ������ջ�����һ���ر��е�״̬) *���һ�����ӱ�����(����SYN�Ѿ������ջ�����һ���ر��е�״̬)
*���ӱ��ر��ˣ�����������һ�����ڹرյ�״̬ *���ӱ��ر��ˣ�����������һ�����ڹرյ�״̬
*pcb�Զ���tcp_slowtmr()�ͷ�,�����������Dz���ȫ�� *pcb�Զ���tcp_slowtmr()�ͷ�,�����������Dz���ȫ��
*/ */
err_t err_t
tcp_close(struct tcp_pcb *pcb) tcp_close(struct tcp_pcb *pcb)
{ {
...@@ -341,7 +341,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) ...@@ -341,7 +341,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
u32_t seqno, ackno; u32_t seqno, ackno;
u16_t remote_port, local_port; u16_t remote_port, local_port;
ip_addr_t remote_ip, local_ip; ip_addr_t remote_ip, local_ip;
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
tcp_err_fn errf; tcp_err_fn errf;
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
void *errf_arg; void *errf_arg;
...@@ -373,7 +373,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) ...@@ -373,7 +373,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
if (pcb->unsent != NULL) { if (pcb->unsent != NULL) {
tcp_segs_free(pcb->unsent); tcp_segs_free(pcb->unsent);
} }
#if TCP_QUEUE_OOSEQ #if TCP_QUEUE_OOSEQ
if (pcb->ooseq != NULL) { if (pcb->ooseq != NULL) {
tcp_segs_free(pcb->ooseq); tcp_segs_free(pcb->ooseq);
} }
...@@ -555,7 +555,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) ...@@ -555,7 +555,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
return (struct tcp_pcb *)lpcb; return (struct tcp_pcb *)lpcb;
} }
/** /**
* Update the state that tracks the available window space to advertise. * Update the state that tracks the available window space to advertise.
* *
* Returns how much extra window would be advertised if we sent an * Returns how much extra window would be advertised if we sent an
...@@ -636,7 +636,7 @@ tcp_new_port(void) ...@@ -636,7 +636,7 @@ tcp_new_port(void)
#define TCP_LOCAL_PORT_RANGE_END 0x7fff #define TCP_LOCAL_PORT_RANGE_END 0x7fff
#endif #endif
static u16_t port = TCP_LOCAL_PORT_RANGE_START; static u16_t port = TCP_LOCAL_PORT_RANGE_START;
again: again:
// if (++port >= TCP_LOCAL_PORT_RANGE_END) { // if (++port >= TCP_LOCAL_PORT_RANGE_END) {
// port = TCP_LOCAL_PORT_RANGE_START; // port = TCP_LOCAL_PORT_RANGE_START;
...@@ -646,7 +646,7 @@ tcp_new_port(void) ...@@ -646,7 +646,7 @@ tcp_new_port(void)
if (port < TCP_LOCAL_PORT_RANGE_START) if (port < TCP_LOCAL_PORT_RANGE_START)
port += TCP_LOCAL_PORT_RANGE_START; port += TCP_LOCAL_PORT_RANGE_START;
/* Check all PCB lists. */ /* Check all PCB lists. */
for (i = 0; i < NUM_TCP_PCB_LISTS; i++) { for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) { for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
if (pcb->local_port == port) { if (pcb->local_port == port) {
goto again; goto again;
...@@ -743,7 +743,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, ...@@ -743,7 +743,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
pcb->ssthresh = pcb->mss * 10; pcb->ssthresh = pcb->mss * 10;
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
pcb->connected = connected;//ע��connected�ص����� pcb->connected = connected;//ע��connected�ص�����
#else /* LWIP_CALLBACK_API */ #else /* LWIP_CALLBACK_API */
LWIP_UNUSED_ARG(connected); LWIP_UNUSED_ARG(connected);
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
...@@ -849,7 +849,7 @@ tcp_slowtmr(void) ...@@ -849,7 +849,7 @@ tcp_slowtmr(void)
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F
" ssthresh %"U16_F"\n", " ssthresh %"U16_F"\n",
pcb->cwnd, pcb->ssthresh)); pcb->cwnd, pcb->ssthresh));
/* The following needs to be called AFTER cwnd is set to one /* The following needs to be called AFTER cwnd is set to one
mss - STJ */ mss - STJ */
tcp_rexmit_rto(pcb); tcp_rexmit_rto(pcb);
...@@ -873,7 +873,7 @@ tcp_slowtmr(void) ...@@ -873,7 +873,7 @@ tcp_slowtmr(void)
if((u32_t)(tcp_ticks - pcb->tmr) > if((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + (pcb->keep_cnt*pcb->keep_intvl)) (pcb->keep_idle + (pcb->keep_cnt*pcb->keep_intvl))
/ TCP_SLOW_INTERVAL) / TCP_SLOW_INTERVAL)
#else #else
if((u32_t)(tcp_ticks - pcb->tmr) > if((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + TCP_MAXIDLE) / TCP_SLOW_INTERVAL) (pcb->keep_idle + TCP_MAXIDLE) / TCP_SLOW_INTERVAL)
#endif /* LWIP_TCP_KEEPALIVE */ #endif /* LWIP_TCP_KEEPALIVE */
...@@ -881,17 +881,17 @@ tcp_slowtmr(void) ...@@ -881,17 +881,17 @@ tcp_slowtmr(void)
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n", LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n",
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
++pcb_remove; ++pcb_remove;
++pcb_reset; ++pcb_reset;
} }
#if LWIP_TCP_KEEPALIVE #if LWIP_TCP_KEEPALIVE
else if((u32_t)(tcp_ticks - pcb->tmr) > else if((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + pcb->keep_cnt_sent * pcb->keep_intvl) (pcb->keep_idle + pcb->keep_cnt_sent * pcb->keep_intvl)
/ TCP_SLOW_INTERVAL) / TCP_SLOW_INTERVAL)
#else #else
else if((u32_t)(tcp_ticks - pcb->tmr) > else if((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEPINTVL_DEFAULT) (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEPINTVL_DEFAULT)
/ TCP_SLOW_INTERVAL) / TCP_SLOW_INTERVAL)
#endif /* LWIP_TCP_KEEPALIVE */ #endif /* LWIP_TCP_KEEPALIVE */
{ {
...@@ -942,12 +942,12 @@ tcp_slowtmr(void) ...@@ -942,12 +942,12 @@ tcp_slowtmr(void)
LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb); LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb);
tcp_active_pcbs = pcb->next; tcp_active_pcbs = pcb->next;
} }
if (pcb_reset) { if (pcb_reset) {
tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
pcb->local_port, pcb->remote_port); pcb->local_port, pcb->remote_port);
} }
TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_ABRT); TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_ABRT);
pcb2 = pcb; pcb2 = pcb;
pcb = pcb->next; pcb = pcb->next;
...@@ -971,7 +971,7 @@ tcp_slowtmr(void) ...@@ -971,7 +971,7 @@ tcp_slowtmr(void)
} }
} }
/* Steps through all of the TIME-WAIT PCBs. */ /* Steps through all of the TIME-WAIT PCBs. */
prev = NULL; prev = NULL;
pcb = tcp_tw_pcbs; pcb = tcp_tw_pcbs;
...@@ -983,7 +983,7 @@ tcp_slowtmr(void) ...@@ -983,7 +983,7 @@ tcp_slowtmr(void)
if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) {
++pcb_remove; ++pcb_remove;
} }
/* If the PCB should be removed, do it. */ /* If the PCB should be removed, do it. */
...@@ -1101,7 +1101,7 @@ tcp_setprio(struct tcp_pcb *pcb, u8_t prio) ...@@ -1101,7 +1101,7 @@ tcp_setprio(struct tcp_pcb *pcb, u8_t prio)
* *
* @param seg the old tcp_seg * @param seg the old tcp_seg
* @return a copy of seg * @return a copy of seg
*/ */
struct tcp_seg * struct tcp_seg *
tcp_seg_copy(struct tcp_seg *seg) tcp_seg_copy(struct tcp_seg *seg)
{ {
...@@ -1111,7 +1111,7 @@ tcp_seg_copy(struct tcp_seg *seg) ...@@ -1111,7 +1111,7 @@ tcp_seg_copy(struct tcp_seg *seg)
if (cseg == NULL) { if (cseg == NULL) {
return NULL; return NULL;
} }
SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg));
pbuf_ref(cseg->p); pbuf_ref(cseg->p);
return cseg; return cseg;
} }
...@@ -1150,7 +1150,7 @@ tcp_kill_prio(u8_t prio) ...@@ -1150,7 +1150,7 @@ tcp_kill_prio(u8_t prio)
mprio = TCP_PRIO_MAX; mprio = TCP_PRIO_MAX;
/* We kill the oldest active connection that has lower priority than prio. */ /* We kill the oldest active connection that has lower priority than prio. */
inactivity = 0; inactivity = 0;
inactive = NULL; inactive = NULL;
...@@ -1207,7 +1207,7 @@ tcp_alloc(u8_t prio) ...@@ -1207,7 +1207,7 @@ tcp_alloc(u8_t prio)
{ {
struct tcp_pcb *pcb; struct tcp_pcb *pcb;
u32_t iss; u32_t iss;
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);//�����ڴ�ؿռ� pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);//�����ڴ�ؿռ�
if (pcb == NULL) { if (pcb == NULL) {
//os_printf("tcp_pcb memory is fail\n"); //os_printf("tcp_pcb memory is fail\n");
...@@ -1253,18 +1253,18 @@ tcp_alloc(u8_t prio) ...@@ -1253,18 +1253,18 @@ tcp_alloc(u8_t prio)
pcb->snd_wl2 = iss; //��ʼ�����ʹ��ڸ����ֶ� pcb->snd_wl2 = iss; //��ʼ�����ʹ��ڸ����ֶ�
pcb->snd_nxt = iss; pcb->snd_nxt = iss;
pcb->lastack = iss; pcb->lastack = iss;
pcb->snd_lbb = iss; pcb->snd_lbb = iss;
pcb->tmr = tcp_ticks; //��¼���ƿ鴴��ϵͳʱ�� pcb->tmr = tcp_ticks; //��¼���ƿ鴴��ϵͳʱ��
pcb->polltmr = 0; //����������¼���ʱ�� pcb->polltmr = 0; //����������¼���ʱ��
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
pcb->recv = tcp_recv_null; //ע�������ݵ�Ĭ���ϲ㺯�� pcb->recv = tcp_recv_null; //ע�������ݵ�Ĭ���ϲ㺯��
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
/* Init KEEPALIVE timer */ /* Init KEEPALIVE timer */
pcb->keep_idle = TCP_KEEPIDLE_DEFAULT; pcb->keep_idle = TCP_KEEPIDLE_DEFAULT;
#if LWIP_TCP_KEEPALIVE #if LWIP_TCP_KEEPALIVE
pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT; pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT;
pcb->keep_cnt = TCP_KEEPCNT_DEFAULT; pcb->keep_cnt = TCP_KEEPCNT_DEFAULT;
...@@ -1300,10 +1300,10 @@ tcp_new(void) ...@@ -1300,10 +1300,10 @@ tcp_new(void)
* ���ֶν���Ϊ����ݸ�������� * ���ֶν���Ϊ����ݸ��������
* @param pcb tcp_pcb to set the callback argument * @param pcb tcp_pcb to set the callback argument
* @param arg void pointer argument to pass to callback functions * @param arg void pointer argument to pass to callback functions
*/ */
void void
tcp_arg(struct tcp_pcb *pcb, void *arg) tcp_arg(struct tcp_pcb *pcb, void *arg)
{ {
pcb->callback_arg = arg; pcb->callback_arg = arg;
} }
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
...@@ -1314,7 +1314,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg) ...@@ -1314,7 +1314,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg)
*����ƿ��recv�ֶ�ע�ắ���յ����ʱ�ص� *����ƿ��recv�ֶ�ע�ắ���յ����ʱ�ص�
* @param pcb tcp_pcb to set the recv callback * @param pcb tcp_pcb to set the recv callback
* @param recv callback function to call for this pcb when data is received * @param recv callback function to call for this pcb when data is received
*/ */
void void
tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
{ {
...@@ -1327,7 +1327,7 @@ tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) ...@@ -1327,7 +1327,7 @@ tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
*����ƿ�send �ֶ�ע�ắ����ݷ��ͳɹ���ص� *����ƿ�send �ֶ�ע�ắ����ݷ��ͳɹ���ص�
* @param pcb tcp_pcb to set the sent callback * @param pcb tcp_pcb to set the sent callback
* @param sent callback function to call for this pcb when data is successfully sent * @param sent callback function to call for this pcb when data is successfully sent
*/ */
void void
tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
{ {
...@@ -1341,7 +1341,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) ...@@ -1341,7 +1341,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
* @param pcb tcp_pcb to set the err callback * @param pcb tcp_pcb to set the err callback
* @param err callback function to call for this pcb when a fatal error * @param err callback function to call for this pcb when a fatal error
* has occured on the connection * has occured on the connection
*/ */
void void
tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
{ {
...@@ -1355,7 +1355,7 @@ tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) ...@@ -1355,7 +1355,7 @@ tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
* @param pcb tcp_pcb to set the accept callback * @param pcb tcp_pcb to set the accept callback
* @param accept callback function to call for this pcb when LISTENing * @param accept callback function to call for this pcb when LISTENing
* connection has been connected to another host * connection has been connected to another host
*/ */
void void
tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
{ {
...@@ -1369,15 +1369,15 @@ tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) ...@@ -1369,15 +1369,15 @@ tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
* from TCP. The interval is specified in terms of the TCP coarse * from TCP. The interval is specified in terms of the TCP coarse
* timer interval, which is called twice a second. * timer interval, which is called twice a second.
*����ƿ��POLL�ֶ�ע�ắ��ú��������Ա����� *����ƿ��POLL�ֶ�ע�ắ��ú��������Ա�����
*/ */
void void
tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)
{ {
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
pcb->poll = poll; pcb->poll = poll;
#else /* LWIP_CALLBACK_API */ #else /* LWIP_CALLBACK_API */
LWIP_UNUSED_ARG(poll); LWIP_UNUSED_ARG(poll);
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
pcb->pollinterval = interval; pcb->pollinterval = interval;
} }
...@@ -1461,7 +1461,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) ...@@ -1461,7 +1461,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
TCP_RMV(pcblist, pcb); TCP_RMV(pcblist, pcb);
tcp_pcb_purge(pcb); tcp_pcb_purge(pcb);
/* if there is an outstanding delayed ACKs, send it */ /* if there is an outstanding delayed ACKs, send it */
if (pcb->state != TIME_WAIT && if (pcb->state != TIME_WAIT &&
pcb->state != LISTEN && pcb->state != LISTEN &&
...@@ -1492,7 +1492,7 @@ u32_t ...@@ -1492,7 +1492,7 @@ u32_t
tcp_next_iss(void) tcp_next_iss(void)
{ {
static u32_t iss = 6510; static u32_t iss = 6510;
again: again:
iss += tcp_ticks; /* XXX */ iss += tcp_ticks; /* XXX */
if (iss == 0) if (iss == 0)
...@@ -1632,21 +1632,21 @@ tcp_debug_print_pcbs(void) ...@@ -1632,21 +1632,21 @@ tcp_debug_print_pcbs(void)
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
} }
LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n"));
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ",
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
} }
LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n"));
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ",
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
} }
} }
/** /**
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* These functions are generally called in the order (ip_input() ->) * These functions are generally called in the order (ip_input() ->)
* tcp_input() -> * tcp_process() -> tcp_receive() (-> application). * tcp_input() -> * tcp_process() -> tcp_receive() (-> application).
* *
*/ */
/* /*
...@@ -92,12 +92,12 @@ static err_t tcp_timewait_input(struct tcp_pcb *pcb)ICACHE_FLASH_ATTR; ...@@ -92,12 +92,12 @@ static err_t tcp_timewait_input(struct tcp_pcb *pcb)ICACHE_FLASH_ATTR;
* @param p received TCP segment to process (p->payload pointing to the IP header) * @param p received TCP segment to process (p->payload pointing to the IP header)
* @param inp network interface on which this segment was received * @param inp network interface on which this segment was received
*/ */
/** /**
* TCP��ʼ�����봦�?��֤��TCPͷ���������IP����� * TCP��ʼ�����봦�?��֤��TCPͷ���������IP�����
* @����p:������յ�TCP��(ָ��IPͷ�ĸ���) * @����p:������յ�TCP��(ָ��IPͷ�ĸ���)
* @����inp:���նε�����ӿ� * @����inp:���նε�����ӿ�
*/ */
void void
tcp_input(struct pbuf *p, struct netif *inp) tcp_input(struct pbuf *p, struct netif *inp)
{ {
...@@ -112,15 +112,15 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -112,15 +112,15 @@ tcp_input(struct pbuf *p, struct netif *inp)
PERF_START; PERF_START;
TCP_STATS_INC(tcp.recv); //״̬��1 TCP_STATS_INC(tcp.recv); //״̬��1
snmp_inc_tcpinsegs(); //tcp����μ�1 snmp_inc_tcpinsegs(); //tcp����μ�1
iphdr = (struct ip_hdr *)p->payload;// pointer to the actual data in the buffer iphdr = (struct ip_hdr *)p->payload;// pointer to the actual data in the buffer
/* /*
*��ͷ����(IHL)��4λ��IPЭ���ͷ�ij��ȣ�ָ��IPv4Э���ͷ���ȵ��ֽ������ٸ�32λ�� *��ͷ����(IHL)��4λ��IPЭ���ͷ�ij��ȣ�ָ��IPv4Э���ͷ���ȵ��ֽ������ٸ�32λ��
*����IPv4�İ�ͷ���ܰ�ɱ������Ŀ�ѡ ���������ֶο�������ȷ��IPv4��ݱ�����ݲ��ֵ�ƫ������ *����IPv4�İ�ͷ���ܰ�ɱ������Ŀ�ѡ ���������ֶο�������ȷ��IPv4��ݱ�����ݲ��ֵ�ƫ������
*IPv4��ͷ����С������20���ֽڣ����IHL����ֶε���Сֵ��ʮ���Ʊ�ʾ����5 (5x4 = 20�ֽ�)�� *IPv4��ͷ����С������20���ֽڣ����IHL����ֶε���Сֵ��ʮ���Ʊ�ʾ����5 (5x4 = 20�ֽ�)��
*����˵�����ʾ�İ�ͷ�����ֽ�����4�ֽڵı��� *����˵�����ʾ�İ�ͷ�����ֽ�����4�ֽڵı���
*/ */
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
...@@ -135,7 +135,7 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -135,7 +135,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
TCP_STATS_INC(tcp.lenerr);//���󳤶ȼ��� TCP_STATS_INC(tcp.lenerr);//���󳤶ȼ���
TCP_STATS_INC(tcp.drop);//��ֹ���� TCP_STATS_INC(tcp.drop);//��ֹ����
snmp_inc_tcpinerrs(); snmp_inc_tcpinerrs();
pbuf_free(p);//�ͷ�buffer pbuf_free(p);//�ͷ�buffer
return; return;
} }
...@@ -183,23 +183,23 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -183,23 +183,23 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* Convert fields in TCP header to host byte order. */ /* Convert fields in TCP header to host byte order. */
tcphdr->src = ntohs(tcphdr->src); //ת��Դ��ַ tcphdr->src = ntohs(tcphdr->src); //ת��Դ��ַ
tcphdr->dest = ntohs(tcphdr->dest); //ת��Ŀ�ĵ�ַ tcphdr->dest = ntohs(tcphdr->dest); //ת��Ŀ�ĵ�ַ
seqno = tcphdr->seqno = ntohl(tcphdr->seqno); //ת�����к� seqno = tcphdr->seqno = ntohl(tcphdr->seqno); //ת�����к�
ackno = tcphdr->ackno = ntohl(tcphdr->ackno); //ת��Ӧ��� ackno = tcphdr->ackno = ntohl(tcphdr->ackno); //ת��Ӧ���
tcphdr->wnd = ntohs(tcphdr->wnd); //ת��tcp���� tcphdr->wnd = ntohs(tcphdr->wnd); //ת��tcp����
flags = TCPH_FLAGS(tcphdr);//�õ�tcp header�ı�־ flags = TCPH_FLAGS(tcphdr);//�õ�tcp header�ı�־
/* /*
*��־��3λ�����ֶΣ��� *��־��3λ�����ֶΣ���
* ����λ��1λ * ����λ��1λ
* ���ֶ�λ��1λ��ȡֵ��0��������ݱ��ֶΣ���1����ݱ����ֶܷΣ� * ���ֶ�λ��1λ��ȡֵ��0��������ݱ��ֶΣ���1����ݱ����ֶܷΣ�
* ����λ��1λ��ȡֵ��0����ݰ����û�а�1����ݰ�����и��İ� * ����λ��1λ��ȡֵ��0����ݰ����û�а�1����ݰ�����и��İ�
*/ */
tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0);//TCP_FIN �� TCP_SYN ���1�������0 tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0);//TCP_FIN �� TCP_SYN ���1�������0
/* Demultiplex an incoming segment. First, we check if it is destined /* Demultiplex an incoming segment. First, we check if it is destined
for an active connection. ���ȣ�����Ƿ�һ��Ҫ����һ������*/ for an active connection. ���ȣ�����Ƿ�һ��Ҫ����һ������*/
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
prev = NULL; prev = NULL;
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {//������б� for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {//������б�
LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED);
LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
...@@ -286,9 +286,9 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -286,9 +286,9 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* put this listening pcb at the head of the listening list */ /* put this listening pcb at the head of the listening list */
tcp_listen_pcbs.listen_pcbs = lpcb; tcp_listen_pcbs.listen_pcbs = lpcb;
} }
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));
tcp_listen_input(lpcb);//����tcp������ݰ� tcp_listen_input(lpcb);//����tcp������ݰ�
pbuf_free(p); pbuf_free(p);
return; return;
} }
...@@ -385,7 +385,7 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -385,7 +385,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
//PSH��־ PSH ����λ�� //PSH��־ PSH ����λ��
//��PSH=1ʱ��Ҫ���ͷ����Ϸ��͸÷ֶΣ� //��PSH=1ʱ��Ҫ���ͷ����Ϸ��͸÷ֶΣ�
//����շ�����Ľ����Ľ���Ӧ�ò㣬�������д��? //����շ�����Ľ����Ľ���Ӧ�ò㣬�������д��?
if (flags & TCP_PSH) { if (flags & TCP_PSH) {
recv_data->flags |= PBUF_FLAG_PUSH;//���bufferӦ������������ recv_data->flags |= PBUF_FLAG_PUSH;//���bufferӦ������������
} }
...@@ -411,7 +411,7 @@ tcp_input(struct pbuf *p, struct netif *inp) ...@@ -411,7 +411,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (pcb->rcv_wnd != TCP_WND) { if (pcb->rcv_wnd != TCP_WND) {
pcb->rcv_wnd++; pcb->rcv_wnd++;
} }
TCP_EVENT_CLOSED(pcb, err); TCP_EVENT_CLOSED(pcb, err);
if (err == ERR_ABRT) { if (err == ERR_ABRT) {
goto aborted; goto aborted;
...@@ -595,21 +595,21 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) ...@@ -595,21 +595,21 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
static err_t static err_t
tcp_timewait_input(struct tcp_pcb *pcb) tcp_timewait_input(struct tcp_pcb *pcb)
{ {
if (flags & TCP_RST) { //RST��λ��ֱ�ӷ��� if (flags & TCP_RST) { //RST��λ��ֱ�ӷ���
return ERR_OK; return ERR_OK;
} }
if (flags & TCP_SYN) { //��SYN������Ϣ����������ݱ���ڽ��մ����ڣ����ͷ�����RST���� if (flags & TCP_SYN) { //��SYN������Ϣ����������ݱ���ڽ��մ����ڣ����ͷ�����RST����
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) {
tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(),
tcphdr->dest, tcphdr->src); tcphdr->dest, tcphdr->src);
return ERR_OK; return ERR_OK;
} }
} else if (flags & TCP_FIN) { //���İ�FIN������Ϣ } else if (flags & TCP_FIN) { //���İ�FIN������Ϣ
pcb->tmr = tcp_ticks; //��λ�ȴ�2MSLʱ�䣬���ƿ����µȴ�2MSL pcb->tmr = tcp_ticks; //��λ�ȴ�2MSLʱ�䣬���ƿ����µȴ�2MSL
} }
...@@ -648,7 +648,7 @@ tcp_process(struct tcp_pcb *pcb) ...@@ -648,7 +648,7 @@ tcp_process(struct tcp_pcb *pcb)
acceptable = 1; acceptable = 1;
} }
} else { } else {
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
pcb->rcv_nxt+pcb->rcv_wnd)) { pcb->rcv_nxt+pcb->rcv_wnd)) {
acceptable = 1; acceptable = 1;
} }
...@@ -669,12 +669,12 @@ tcp_process(struct tcp_pcb *pcb) ...@@ -669,12 +669,12 @@ tcp_process(struct tcp_pcb *pcb)
} }
} }
if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) {
/* Cope with new connection attempt after remote end crashed */ /* Cope with new connection attempt after remote end crashed */
tcp_ack_now(pcb); tcp_ack_now(pcb);
return ERR_OK; return ERR_OK;
} }
if ((pcb->flags & TF_RXCLOSED) == 0) { if ((pcb->flags & TF_RXCLOSED) == 0) {
/* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */ /* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */
pcb->tmr = tcp_ticks; pcb->tmr = tcp_ticks;
...@@ -939,7 +939,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -939,7 +939,7 @@ tcp_receive(struct tcp_pcb *pcb)
#if TCP_WND_DEBUG #if TCP_WND_DEBUG
} else { } else {
if (pcb->snd_wnd != tcphdr->wnd) { if (pcb->snd_wnd != tcphdr->wnd) {
LWIP_DEBUGF(TCP_WND_DEBUG, LWIP_DEBUGF(TCP_WND_DEBUG,
("tcp_receive: no window update lastack %"U32_F" ackno %" ("tcp_receive: no window update lastack %"U32_F" ackno %"
U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n",
pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2));
...@@ -954,12 +954,12 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -954,12 +954,12 @@ tcp_receive(struct tcp_pcb *pcb)
* 3) the advertised window hasn't changed ���ش���û�и��� * 3) the advertised window hasn't changed ���ش���û�и���
* 4) There is outstanding unacknowledged data (retransmission timer running)������ݵȴ�ȷ�� * 4) There is outstanding unacknowledged data (retransmission timer running)������ݵȴ�ȷ��
* 5) The ACK is == biggest ACK sequence number so far seen (snd_una) ackno = lastack * 5) The ACK is == biggest ACK sequence number so far seen (snd_una) ackno = lastack
* *
* If it passes all five, should process as a dupack: * If it passes all five, should process as a dupack:
* a) dupacks < 3: do nothing * a) dupacks < 3: do nothing
* b) dupacks == 3: fast retransmit * b) dupacks == 3: fast retransmit
* c) dupacks > 3: increase cwnd * c) dupacks > 3: increase cwnd
* *
* If it only passes 1-3, should reset dupack counter (and add to * If it only passes 1-3, should reset dupack counter (and add to
* stats, which we don't do in lwIP) * stats, which we don't do in lwIP)
* *
...@@ -1002,10 +1002,10 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1002,10 +1002,10 @@ tcp_receive(struct tcp_pcb *pcb)
} }
} else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){//ackno��lastack+1��snd_nxt֮�䣬�жϷ��ʹ�������� } else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){//ackno��lastack+1��snd_nxt֮�䣬�жϷ��ʹ��������
/* We come here when the ACK acknowledges new data. */ /* We come here when the ACK acknowledges new data. */
if (pcb->flags & TF_INFR) { if (pcb->flags & TF_INFR) {
pcb->flags &= ~TF_INFR;// Reset the "IN Fast Retransmit" flag,since we are no longer in fast retransmit pcb->flags &= ~TF_INFR;// Reset the "IN Fast Retransmit" flag,since we are no longer in fast retransmit
pcb->cwnd = pcb->ssthresh;//Reset the congestion window to the "slow start threshold". pcb->cwnd = pcb->ssthresh;//Reset the congestion window to the "slow start threshold".
} }
/* Reset the number of retransmissions. */ /* Reset the number of retransmissions. */
...@@ -1047,7 +1047,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1047,7 +1047,7 @@ tcp_receive(struct tcp_pcb *pcb)
ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0));
/* Remove segment from the unacknowledged list if the incoming /* Remove segment from the unacknowledged list if the incoming
ACK acknowlegdes them. ACK acknowlegdes them.
*�ͷ�unacked�����ϱ�ȷ�ϵı��ĶΣ� *�ͷ�unacked�����ϱ�ȷ�ϵı��ĶΣ�
*ֱ��unacked����Ϊ��ֹͣ*/ *ֱ��unacked����Ϊ��ֹͣ*/
while (pcb->unacked != NULL && while (pcb->unacked != NULL &&
...@@ -1068,7 +1068,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1068,7 +1068,7 @@ tcp_receive(struct tcp_pcb *pcb)
pcb->acked--; pcb->acked--;
} }
pcb->snd_queuelen -= pbuf_clen(next->p);//�������������pbufs���� pcb->snd_queuelen -= pbuf_clen(next->p);//�������������pbufs����
tcp_seg_free(next);//�ͷ�tcp�� tcp_seg_free(next);//�ͷ�tcp��
LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen));
...@@ -1099,13 +1099,13 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1099,13 +1099,13 @@ tcp_receive(struct tcp_pcb *pcb)
in fact have been sent once. */ in fact have been sent once. */
/** unsent�������Ƿ��ܱ�acknoȷ�ϵı��ĶΣ������ͷ�**/ /** unsent�������Ƿ��ܱ�acknoȷ�ϵı��ĶΣ������ͷ�**/
while (pcb->unsent != NULL && while (pcb->unsent != NULL &&
TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) +
TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n",
ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) +
TCP_TCPLEN(pcb->unsent))); TCP_TCPLEN(pcb->unsent)));
next = pcb->unsent;//pcbδ���ͱ�־ next = pcb->unsent;//pcbδ���ͱ�־
pcb->unsent = pcb->unsent->next;//δ���͵���һ�� pcb->unsent = pcb->unsent->next;//δ���͵���һ��
LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen));
LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p)));
...@@ -1252,7 +1252,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1252,7 +1252,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* The sequence number must be within the window (above rcv_nxt /* The sequence number must be within the window (above rcv_nxt
and below rcv_nxt + rcv_wnd) in order to be further and below rcv_nxt + rcv_wnd) in order to be further
processed. */ processed. */
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
pcb->rcv_nxt + pcb->rcv_wnd - 1)){//rcv_nxt < seqno < rcv_nxt + rcv_wnd - 1,������ڽ��շ�Χ�� pcb->rcv_nxt + pcb->rcv_wnd - 1)){//rcv_nxt < seqno < rcv_nxt + rcv_wnd - 1,������ڽ��շ�Χ��
if (pcb->rcv_nxt == seqno) { if (pcb->rcv_nxt == seqno) {
/* The incoming segment is the next in sequence. We check if /* The incoming segment is the next in sequence. We check if
...@@ -1261,12 +1261,12 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1261,12 +1261,12 @@ tcp_receive(struct tcp_pcb *pcb)
tcplen = TCP_TCPLEN(&inseg);//���㱨�Ķγ��� tcplen = TCP_TCPLEN(&inseg);//���㱨�Ķγ���
if (tcplen > pcb->rcv_wnd) {//������մ��ڴ�С��������β���ض� if (tcplen > pcb->rcv_wnd) {//������մ��ڴ�С��������β���ض�
LWIP_DEBUGF(TCP_INPUT_DEBUG, LWIP_DEBUGF(TCP_INPUT_DEBUG,
("tcp_receive: other end overran receive window" ("tcp_receive: other end overran receive window"
"seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n",
seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd));
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
/* Must remove the FIN from the header as we're trimming /* Must remove the FIN from the header as we're trimming
* that byte of sequence-space from the packet */ * that byte of sequence-space from the packet */
TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN); TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN);
} }
...@@ -1286,7 +1286,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1286,7 +1286,7 @@ tcp_receive(struct tcp_pcb *pcb)
- inseq overlaps with ooseq */ - inseq overlaps with ooseq */
if (pcb->ooseq != NULL) { if (pcb->ooseq != NULL) {
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, LWIP_DEBUGF(TCP_INPUT_DEBUG,
("tcp_receive: received in-order FIN, binning ooseq queue\n")); ("tcp_receive: received in-order FIN, binning ooseq queue\n"));
/* Received in-order FIN means anything that was received /* Received in-order FIN means anything that was received
* out of order must now have been received in-order, so * out of order must now have been received in-order, so
...@@ -1394,7 +1394,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1394,7 +1394,7 @@ tcp_receive(struct tcp_pcb *pcb)
recv_flags |= TF_GOT_FIN; recv_flags |= TF_GOT_FIN;
if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */ if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */
pcb->state = CLOSE_WAIT; pcb->state = CLOSE_WAIT;
} }
} }
pcb->ooseq = cseg->next; pcb->ooseq = cseg->next;
...@@ -1507,12 +1507,12 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1507,12 +1507,12 @@ tcp_receive(struct tcp_pcb *pcb)
} }
/* check if the remote side overruns our receive window */ /* check if the remote side overruns our receive window */
if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, LWIP_DEBUGF(TCP_INPUT_DEBUG,
("tcp_receive: other end overran receive window" ("tcp_receive: other end overran receive window"
"seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n",
seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd));
if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) {
/* Must remove the FIN from the header as we're trimming /* Must remove the FIN from the header as we're trimming
* that byte of sequence-space from the packet */ * that byte of sequence-space from the packet */
TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN); TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN);
} }
...@@ -1549,7 +1549,7 @@ tcp_receive(struct tcp_pcb *pcb) ...@@ -1549,7 +1549,7 @@ tcp_receive(struct tcp_pcb *pcb)
} }
/** /**
* Parses the options contained in the incoming segment. * Parses the options contained in the incoming segment.
* *
* Called from tcp_listen_input() and tcp_process(). * Called from tcp_listen_input() and tcp_process().
* Currently, only the MSS option is supported! * Currently, only the MSS option is supported!
...@@ -1606,7 +1606,7 @@ tcp_parseopt(struct tcp_pcb *pcb) ...@@ -1606,7 +1606,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
return; return;
} }
/* TCP timestamp option with valid length */ /* TCP timestamp option with valid length */
tsval = (opts[c+2]) | (opts[c+3] << 8) | tsval = (opts[c+2]) | (opts[c+3] << 8) |
(opts[c+4] << 16) | (opts[c+5] << 24); (opts[c+4] << 16) | (opts[c+5] << 24);
if (flags & TCP_SYN) { if (flags & TCP_SYN) {
pcb->ts_recent = ntohl(tsval); pcb->ts_recent = ntohl(tsval);
......
...@@ -199,7 +199,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, ...@@ -199,7 +199,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
/* wnd and chksum are set in tcp_output */ /* wnd and chksum are set in tcp_output */
seg->tcphdr->urgp = 0; seg->tcphdr->urgp = 0;
return seg; return seg;
} }
/** /**
* Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. * Allocate a PBUF_RAM pbuf, perhaps with extra space at the end.
...@@ -214,7 +214,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, ...@@ -214,7 +214,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
* @param pcb The TCP connection that willo enqueue the pbuf. * @param pcb The TCP connection that willo enqueue the pbuf.
* @param apiflags API flags given to tcp_write. * @param apiflags API flags given to tcp_write.
* @param first_seg true when this pbuf will be used in the first enqueued segment. * @param first_seg true when this pbuf will be used in the first enqueued segment.
* @param * @param
*/ */
#if TCP_OVERSIZE #if TCP_OVERSIZE
static struct pbuf *ICACHE_FLASH_ATTR static struct pbuf *ICACHE_FLASH_ATTR
...@@ -379,7 +379,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) ...@@ -379,7 +379,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n", LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n",
(void *)pcb, arg, len, (u16_t)apiflags)); (void *)pcb, arg, len, (u16_t)apiflags));
LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)",
arg != NULL, return ERR_ARG;); arg != NULL, return ERR_ARG;);
err = tcp_write_checks(pcb, len); err = tcp_write_checks(pcb, len);
...@@ -821,7 +821,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) ...@@ -821,7 +821,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags)
return ERR_OK; return ERR_OK;
} }
#if LWIP_TCP_TIMESTAMPS #if LWIP_TCP_TIMESTAMPS
/* Build a timestamp option (12 bytes long) at the specified options pointer) /* Build a timestamp option (12 bytes long) at the specified options pointer)
...@@ -862,7 +862,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) ...@@ -862,7 +862,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
return ERR_BUF; return ERR_BUF;
} }
tcphdr = (struct tcp_hdr *)p->payload; tcphdr = (struct tcp_hdr *)p->payload;
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, LWIP_DEBUGF(TCP_OUTPUT_DEBUG,
("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt));
/* remove ACK flags from the PCB, as we send an empty ACK now */ /* remove ACK flags from the PCB, as we send an empty ACK now */
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
...@@ -874,7 +874,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) ...@@ -874,7 +874,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
if (pcb->flags & TF_TIMESTAMP) { if (pcb->flags & TF_TIMESTAMP) {
tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1)); tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1));
} }
#endif #endif
#if CHECKSUM_GEN_TCP #if CHECKSUM_GEN_TCP
tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip), tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
...@@ -950,7 +950,7 @@ tcp_output(struct tcp_pcb *pcb) ...@@ -950,7 +950,7 @@ tcp_output(struct tcp_pcb *pcb)
", seg == NULL, ack %"U32_F"\n", ", seg == NULL, ack %"U32_F"\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack));
} else { } else {
LWIP_DEBUGF(TCP_CWND_DEBUG, LWIP_DEBUGF(TCP_CWND_DEBUG,
("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F
", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->snd_wnd, pcb->cwnd, wnd,
...@@ -958,12 +958,12 @@ tcp_output(struct tcp_pcb *pcb) ...@@ -958,12 +958,12 @@ tcp_output(struct tcp_pcb *pcb)
ntohl(seg->tcphdr->seqno), pcb->lastack)); ntohl(seg->tcphdr->seqno), pcb->lastack));
} }
#endif /* TCP_CWND_DEBUG */ #endif /* TCP_CWND_DEBUG */
/* data available and window allows it to be sent? /* data available and window allows it to be sent?
*��ǰ��Ч�������?�ķ��ͣ�ѭ�����ͱ��ģ�ֱ�������*/ *��ǰ��Ч�������?�ķ��ͣ�ѭ�����ͱ��ģ�ֱ�������*/
while (seg != NULL && while (seg != NULL &&
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd
&& (seg->p->ref<2) ) { && (seg->p->ref<2) ) {
LWIP_ASSERT("RST not expected here!", LWIP_ASSERT("RST not expected here!",
(TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0);
/* Stop sending if the nagle algorithm would prevent it /* Stop sending if the nagle algorithm would prevent it
* Don't stop: * Don't stop:
...@@ -993,7 +993,7 @@ tcp_output(struct tcp_pcb *pcb) ...@@ -993,7 +993,7 @@ tcp_output(struct tcp_pcb *pcb)
} }
tcp_output_segment(seg, pcb);//���ú����ͱ��Ķ� tcp_output_segment(seg, pcb);//���ú����ͱ��Ķ�
snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);//����snd_nxt snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);//����snd_nxt
if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) {
pcb->snd_nxt = snd_nxt;//����Ҫ���͵���ݱ�� pcb->snd_nxt = snd_nxt;//����Ҫ���͵���ݱ��
...@@ -1041,7 +1041,7 @@ tcp_output(struct tcp_pcb *pcb) ...@@ -1041,7 +1041,7 @@ tcp_output(struct tcp_pcb *pcb)
#endif /* TCP_OVERSIZE */ #endif /* TCP_OVERSIZE */
//���ʹ��������±��IJ��ܷ��ͣ��������㴰��̽�⡣ //���ʹ��������±��IJ��ܷ��ͣ��������㴰��̽�⡣
if (seg != NULL && pcb->persist_backoff == 0 && if (seg != NULL && pcb->persist_backoff == 0 &&
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > pcb->snd_wnd) { ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > pcb->snd_wnd) {
/* prepare for persist timer */ /* prepare for persist timer */
pcb->persist_cnt = 0; pcb->persist_cnt = 0;
...@@ -1094,7 +1094,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) ...@@ -1094,7 +1094,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
} }
#endif #endif
/* Set retransmission timer running if it is not currently enabled /* Set retransmission timer running if it is not currently enabled
This must be set before checking the route. modify by ives at 2014.4.24*/ This must be set before checking the route. modify by ives at 2014.4.24*/
if (pcb->rtime == -1) { if (pcb->rtime == -1) {
pcb->rtime = 0; pcb->rtime = 0;
...@@ -1362,12 +1362,12 @@ tcp_rexmit(struct tcp_pcb *pcb) ...@@ -1362,12 +1362,12 @@ tcp_rexmit(struct tcp_pcb *pcb)
* *
* @param pcb the tcp_pcb for which to retransmit the first unacked segment * @param pcb the tcp_pcb for which to retransmit the first unacked segment
*/ */
void void
tcp_rexmit_fast(struct tcp_pcb *pcb) tcp_rexmit_fast(struct tcp_pcb *pcb)
{ {
if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) { if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) {
/* This is fast retransmit. Retransmit the first unacked segment. */ /* This is fast retransmit. Retransmit the first unacked segment. */
LWIP_DEBUGF(TCP_FR_DEBUG, LWIP_DEBUGF(TCP_FR_DEBUG,
("tcp_receive: dupacks %"U16_F" (%"U32_F ("tcp_receive: dupacks %"U16_F" (%"U32_F
"), fast retransmit %"U32_F"\n", "), fast retransmit %"U32_F"\n",
(u16_t)pcb->dupacks, pcb->lastack, (u16_t)pcb->dupacks, pcb->lastack,
...@@ -1381,19 +1381,19 @@ tcp_rexmit_fast(struct tcp_pcb *pcb) ...@@ -1381,19 +1381,19 @@ tcp_rexmit_fast(struct tcp_pcb *pcb)
} else { } else {
pcb->ssthresh = pcb->cwnd / 2; pcb->ssthresh = pcb->cwnd / 2;
} }
/* The minimum value for ssthresh should be 2 MSS */ /* The minimum value for ssthresh should be 2 MSS */
if (pcb->ssthresh < 2*pcb->mss) { if (pcb->ssthresh < 2*pcb->mss) {
LWIP_DEBUGF(TCP_FR_DEBUG, LWIP_DEBUGF(TCP_FR_DEBUG,
("tcp_receive: The minimum value for ssthresh %"U16_F ("tcp_receive: The minimum value for ssthresh %"U16_F
" should be min 2 mss %"U16_F"...\n", " should be min 2 mss %"U16_F"...\n",
pcb->ssthresh, 2*pcb->mss)); pcb->ssthresh, 2*pcb->mss));
pcb->ssthresh = 2*pcb->mss; pcb->ssthresh = 2*pcb->mss;
} }
pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; pcb->cwnd = pcb->ssthresh + 3 * pcb->mss;
pcb->flags |= TF_INFR; pcb->flags |= TF_INFR;
} }
} }
...@@ -1415,12 +1415,12 @@ tcp_keepalive(struct tcp_pcb *pcb) ...@@ -1415,12 +1415,12 @@ tcp_keepalive(struct tcp_pcb *pcb)
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); tcp_ticks, pcb->tmr, pcb->keep_cnt_sent));
p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1));
if(p == NULL) { if(p == NULL) {
LWIP_DEBUGF(TCP_DEBUG, LWIP_DEBUGF(TCP_DEBUG,
("tcp_keepalive: could not allocate memory for pbuf\n")); ("tcp_keepalive: could not allocate memory for pbuf\n"));
return; return;
} }
...@@ -1465,15 +1465,15 @@ tcp_zero_window_probe(struct tcp_pcb *pcb) ...@@ -1465,15 +1465,15 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
u16_t len; u16_t len;
u8_t is_fin; u8_t is_fin;
LWIP_DEBUGF(TCP_DEBUG, LWIP_DEBUGF(TCP_DEBUG,
("tcp_zero_window_probe: sending ZERO WINDOW probe to %" ("tcp_zero_window_probe: sending ZERO WINDOW probe to %"
U16_F".%"U16_F".%"U16_F".%"U16_F"\n", U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
LWIP_DEBUGF(TCP_DEBUG, LWIP_DEBUGF(TCP_DEBUG,
("tcp_zero_window_probe: tcp_ticks %"U32_F ("tcp_zero_window_probe: tcp_ticks %"U32_F
" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); tcp_ticks, pcb->tmr, pcb->keep_cnt_sent));
seg = pcb->unacked; seg = pcb->unacked;
......
...@@ -144,7 +144,7 @@ udp_input(struct pbuf *p, struct netif *inp) ...@@ -144,7 +144,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */ /* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */
if (src == DHCP_SERVER_PORT) { if (src == DHCP_SERVER_PORT) {
if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) { if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) {
/* accept the packe if /* accept the packe if
(- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY! (- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY!
- inp->dhcp->pcb->remote == ANY or iphdr->src */ - inp->dhcp->pcb->remote == ANY or iphdr->src */
if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) || if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) ||
...@@ -196,7 +196,7 @@ udp_input(struct pbuf *p, struct netif *inp) ...@@ -196,7 +196,7 @@ udp_input(struct pbuf *p, struct netif *inp)
(broadcast))) { (broadcast))) {
#endif /* IP_SOF_BROADCAST_RECV */ #endif /* IP_SOF_BROADCAST_RECV */
local_match = 1; local_match = 1;
if ((uncon_pcb == NULL) && if ((uncon_pcb == NULL) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
/* the first unconnected matching PCB */ /* the first unconnected matching PCB */
uncon_pcb = pcb; uncon_pcb = pcb;
...@@ -422,7 +422,7 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, ...@@ -422,7 +422,7 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
* *
* If the PCB already has a remote address association, it will * If the PCB already has a remote address association, it will
* be restored after the data is sent. * be restored after the data is sent.
* *
* @return lwIP error code (@see udp_send for possible error codes) * @return lwIP error code (@see udp_send for possible error codes)
* *
* @see udp_disconnect() udp_send() * @see udp_disconnect() udp_send()
...@@ -553,7 +553,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, ...@@ -553,7 +553,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
udphdr->src = htons(pcb->local_port); udphdr->src = htons(pcb->local_port);
udphdr->dest = htons(dst_port); udphdr->dest = htons(dst_port);
/* in UDP, 0 checksum means 'no checksum' */ /* in UDP, 0 checksum means 'no checksum' */
udphdr->chksum = 0x0000; udphdr->chksum = 0x0000;
/* Multicast Loop? */ /* Multicast Loop? */
#if LWIP_IGMP #if LWIP_IGMP
......
############################################################# #############################################################
# Required variables for each makefile # Required variables for each makefile
# Discard this section from all parent makefiles # Discard this section from all parent makefiles
# Expected variables (with automatic defaults): # Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir) # CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile) # SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated () # GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated () # GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form # COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into # subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a () # a generated lib/image xxx.a ()
# #
ifndef PDIR ifndef PDIR
GEN_LIBS = liblwipnetif.a GEN_LIBS = liblwipnetif.a
endif endif
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here! # Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the # Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden # makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein # for a subtree within the makefile rooted therein
# #
#DEFINES += #DEFINES +=
############################################################# #############################################################
# Recursion Magic - Don't touch this!! # Recursion Magic - Don't touch this!!
# #
# Each subtree potentially has an include directory # Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules # corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH # rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up # of a module can only contain the include directories up
# its parent path, and not its siblings # its parent path, and not its siblings
# #
# Required for each makefile to inherit from the parent # Required for each makefile to inherit from the parent
# #
INCLUDES := $(INCLUDES) -I $(PDIR)include INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./ INCLUDES += -I ./
PDIR := ../$(PDIR) PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile sinclude $(PDIR)Makefile
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment