Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d77666c0
Commit
d77666c0
authored
Feb 17, 2019
by
sergio
Committed by
Terry Ellison
Feb 17, 2019
Browse files
trailing spaces cleanup (#2659)
parent
d7583040
Changes
380
Hide whitespace changes
Inline
Side-by-side
app/lwip/core/ipv4/Makefile
View file @
d77666c0
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
GEN_LIBS
=
liblwipipv4.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
GEN_LIBS
=
liblwipipv4.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
app/lwip/core/ipv4/autoip.c
View file @
d77666c0
...
...
@@ -43,9 +43,9 @@
/*******************************************************************************
* USAGE:
*
*
* 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):
* - First, call autoip_init().
* - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces,
...
...
@@ -55,7 +55,7 @@
*
* Without DHCP:
* - Call autoip_start() after netif_add().
*
*
* With DHCP:
* - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h.
* - Configure your DHCP Client.
...
...
@@ -210,7 +210,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr)
u32_t
addr
=
ntohl
(
LWIP_AUTOIP_CREATE_SEED_ADDR
(
netif
));
addr
+=
netif
->
autoip
->
tried_llipaddr
;
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
)
{
addr
+=
AUTOIP_RANGE_END
-
AUTOIP_RANGE_START
+
1
;
...
...
@@ -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
)
&&
(
addr
<=
AUTOIP_RANGE_END
));
ip4_addr_set_u32
(
ipaddr
,
htonl
(
addr
));
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
"
,
(
u16_t
)(
netif
->
autoip
->
tried_llipaddr
),
ip4_addr1_16
(
ipaddr
),
ip4_addr2_16
(
ipaddr
),
...
...
@@ -276,7 +276,7 @@ autoip_bind(struct netif *netif)
netif_set_ipaddr
(
netif
,
&
autoip
->
llipaddr
);
netif_set_netmask
(
netif
,
&
sn_mask
);
netif_set_gw
(
netif
,
&
gw_addr
);
netif_set_gw
(
netif
,
&
gw_addr
);
/* bring the interface up */
netif_set_up
(
netif
);
...
...
@@ -501,7 +501,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
*/
IPADDR2_COPY
(
&
sipaddr
,
&
hdr
->
sipaddr
);
IPADDR2_COPY
(
&
dipaddr
,
&
hdr
->
dipaddr
);
if
((
netif
->
autoip
->
state
==
AUTOIP_STATE_PROBING
)
||
((
netif
->
autoip
->
state
==
AUTOIP_STATE_ANNOUNCING
)
&&
(
netif
->
autoip
->
sent_num
==
0
)))
{
...
...
app/lwip/core/ipv4/icmp.c
View file @
d77666c0
...
...
@@ -104,7 +104,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
case
ICMP_ER
:
/* This is OK, echo reply might have been parsed by a raw PCB
(as obviously, an echo request has been sent, too). */
break
;
break
;
case
ICMP_ECHO
:
#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
{
...
...
@@ -224,7 +224,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
}
break
;
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
));
ICMP_STATS_INC
(
icmp
.
proterr
);
ICMP_STATS_INC
(
icmp
.
drop
);
...
...
app/lwip/core/ipv4/igmp.c
View file @
d77666c0
...
...
@@ -8,29 +8,29 @@
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 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
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 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
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 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 OF
* SUCH DAMAGE.
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 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 OF
* SUCH DAMAGE.
*
* This file is a contribution to the lwIP TCP/IP stack.
* The Swedish Institute of Computer Science and Adam Dunkels
...
...
@@ -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 3376 - 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__;
#define IGMP_LOG //os_printf
#endif
/*
/*
* IGMP constants
*/
#define IGMP_TTL 1
...
...
@@ -180,18 +180,18 @@ igmp_init(void)
*/
void
igmp_dump_group_list
()
{
{
struct
igmp_group
*
group
=
igmp_group_list
;
IGMP_LOG
(
"igmp_dump:
\n
"
);
while
(
group
!=
NULL
)
{
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"igmp_dump_group_list: [%"
U32_F
"] "
,
(
u32_t
)(
group
->
group_state
)));
ip_addr_debug_print
(
IGMP_DEBUG
,
&
group
->
group_address
);
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
" on if %p
\n
"
,
group
->
netif
));
if
(
group
!=
NULL
)
IGMP_LOG
(
"group:%p,netif:%p
\n
"
,
group
,
group
->
netif
);
group
=
group
->
next
;
}
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"
\n
"
));
...
...
@@ -341,7 +341,7 @@ struct igmp_group *
igmp_lookup_group
(
struct
netif
*
ifp
,
ip_addr_t
*
addr
)
{
struct
igmp_group
*
group
=
igmp_group_list
;
/* Search if the group already exists */
group
=
igmp_lookfor_group
(
ifp
,
addr
);
if
(
group
!=
NULL
)
{
...
...
@@ -421,7 +421,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)
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
;
if
(
pbuf_header
(
p
,
-
(
s16_t
)(
IPH_HL
(
iphdr
)
*
4
))
||
(
p
->
len
<
IGMP_MINLEN
))
{
pbuf_free
(
p
);
...
...
@@ -447,7 +447,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)
/* Packet is ok so find an existing group */
group
=
igmp_lookfor_group
(
inp
,
dest
);
/* use the destination IP address of incoming packet */
/* If group can be found or create... */
if
(
!
group
)
{
pbuf_free
(
p
);
...
...
@@ -640,7 +640,7 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)
IGMP_STATS_INC
(
igmp
.
tx_leave
);
igmp_send
(
group
,
IGMP_LEAVE_GROUP
);
}
/* Disable the group at the MAC level */
if
(
netif
->
igmp_mac_filter
!=
NULL
)
{
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"igmp_leavegroup: igmp_mac_filter(DEL "
));
...
...
@@ -648,11 +648,11 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
") on if %p
\n
"
,
netif
));
netif
->
igmp_mac_filter
(
netif
,
groupaddr
,
IGMP_DEL_MAC_FILTER
);
}
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"igmp_leavegroup: remove group: "
));
ip_addr_debug_print
(
IGMP_DEBUG
,
groupaddr
);
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"
\n
"
));
LWIP_DEBUGF
(
IGMP_DEBUG
,
(
"
\n
"
));
/* Free the group */
igmp_remove_group
(
group
);
}
else
{
...
...
@@ -808,13 +808,13 @@ igmp_send(struct igmp_group *group, u8_t type)
/* IP header + "router alert" option + IGMP header */
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
IGMP_MINLEN
,
PBUF_RAM
);
if
(
p
)
{
igmp
=
(
struct
igmp_msg
*
)
p
->
payload
;
LWIP_ASSERT
(
"igmp_send: check that first pbuf can hold struct igmp_msg"
,
(
p
->
len
>=
sizeof
(
struct
igmp_msg
)));
ip_addr_copy
(
src
,
group
->
netif
->
ip_addr
);
if
(
type
==
IGMP_V2_MEMB_REPORT
)
{
dest
=
&
(
group
->
group_address
);
ip_addr_copy
(
igmp
->
igmp_group_address
,
group
->
group_address
);
...
...
app/lwip/core/ipv4/inet_chksum.c
View file @
d77666c0
...
...
@@ -48,8 +48,8 @@
* aim of being simple, correct and fully portable. Checksumming is the
* 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:
*
* #define LWIP_CHKSUM <your_checksum_routine>
*
* #define LWIP_CHKSUM <your_checksum_routine>
*
* Or you can select from the implementations below by defining
* LWIP_CHKSUM_ALGORITHM to 1, 2 or 3.
...
...
@@ -72,7 +72,7 @@
*
* @param dataptr points to start of data to be summed at any boundary
* @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 host endianess is irrelevant (p3 RFC1071)
...
...
@@ -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 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
...
...
@@ -178,12 +178,12 @@ lwip_standard_chksum(void *dataptr, int len)
/**
* An optimized checksum routine. Basically, it uses loop-unrolling on
* 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.
* @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
*/
...
...
app/lwip/core/ipv4/ip.c
View file @
d77666c0
/**
* @file
* This is the IPv4 layer implementation for incoming and outgoing IP traffic.
*
*
* @see ip_frag.c
*
*/
...
...
@@ -171,7 +171,7 @@ ip_router(ip_addr_t *dest, ip_addr_t *source){
/* iterate through netifs */
for
(
netif
=
netif_list
;
netif
!=
NULL
;
netif
=
netif
->
next
)
{
/* network mask matches? */
if
(
netif_is_up
(
netif
))
{
if
(
ip_addr_netcmp
(
dest
,
&
(
netif
->
ip_addr
),
&
(
netif
->
netmask
)))
{
/* return netif on which to forward IP packet */
...
...
@@ -285,7 +285,7 @@ return_noroute:
* forwarded (using ip_forward). The IP checksum is always checked.
*
* 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 inp the netif on which this packet was received
* @return ERR_OK if the packet was processed (could return ERR_* if it wasn't
...
...
app/lwip/core/ipv4/ip_addr.c
View file @
d77666c0
...
...
@@ -6,9 +6,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 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
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
@@ -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
};
/**
* 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 netif the network interface against which the address is checked
* @return returns non-zero if the address is a broadcast address
...
...
app/lwip/core/ipv4/ip_frag.c
View file @
d77666c0
...
...
@@ -6,9 +6,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,25 +17,25 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 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
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Jani Monoses <jani@iv.ro>
*
* Author: Jani Monoses <jani@iv.ro>
* Simon Goldschmidt
* original reassembly code by Adam Dunkels <adam@sics.se>
*
*
*/
#include "lwip/opt.h"
...
...
@@ -185,7 +185,7 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
}
#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 */
p
=
ipr
->
p
;
while
(
p
!=
NULL
)
{
...
...
@@ -303,7 +303,7 @@ ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen)
static
void
ICACHE_FLASH_ATTR
ip_reass_dequeue_datagram
(
struct
ip_reassdata
*
ipr
,
struct
ip_reassdata
*
prev
)
{
/* dequeue the reass struct */
if
(
reassdatagrams
==
ipr
)
{
/* it was the first in the list */
...
...
@@ -337,7 +337,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
int
valid
=
1
;
/* 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
;
offset
=
(
ntohs
(
IPH_OFFSET
(
fraghdr
))
&
IP_OFFMASK
)
*
8
;
...
...
@@ -538,7 +538,7 @@ ip_reass(struct pbuf *p)
goto
nullreturn
;
}
}
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
))
{
/* 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
...
...
@@ -547,11 +547,11 @@ ip_reass(struct pbuf *p)
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 */
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 */
/* check for 'no more fragments', and update queue entry*/
...
...
@@ -663,7 +663,7 @@ ipfrag_free_pbuf_custom(struct pbuf *p)
*
* @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
)
{
struct
pbuf
*
rambuf
;
...
...
@@ -818,8 +818,8 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
pbuf_realloc
(
rambuf
,
left
+
IP_HLEN
);
}
/* This part is ugly: we alloc a RAM based pbuf for
* the link level header for each chunk and then
/* This part is ugly: we alloc a RAM based pbuf for
* the link level header for each chunk and then
* free it.A PBUF_ROM style pbuf for which pbuf_header
* worked would make things simpler.
*/
...
...
@@ -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
* there will be zero memory penalty.
*/
pbuf_free
(
rambuf
);
#endif
/* IP_FRAG_USES_STATIC_BUF */
left
-=
cop
;
...
...
app/lwip/core/mem.c
View file @
d77666c0
...
...
@@ -470,7 +470,7 @@ mem_trim(void *rmem, mem_size_t newsize)
/* else {
next struct mem is used but size between mem and mem2 is not big enough
to create another struct mem
-> don't do anyhting.
-> don't do anyhting.
-> the remaining space stays unused since it is too small
} */
#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
...
...
app/lwip/core/memp.c
View file @
d77666c0
...
...
@@ -8,9 +8,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -19,21 +19,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 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
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
@@ -158,19 +158,19 @@ const char *memp_desc[MEMP_MAX] = {
* 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 \
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] attr;
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] attr;
#include "lwip/memp_std.h"
/** This array holds the base of each memory pool. */
static
u8_t
*
const
memp_bases
[]
=
{
#define LWIP_MEMPOOL(name,num,size,desc,attr) memp_memory_ ## name ## _base,
static
u8_t
*
const
memp_bases
[]
=
{
#define LWIP_MEMPOOL(name,num,size,desc,attr) memp_memory_ ## name ## _base,
#include "lwip/memp_std.h"
};
#else
/* MEMP_SEPARATE_POOLS */
/** 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) ) )
#include "lwip/memp_std.h"
];
...
...
@@ -334,7 +334,7 @@ memp_overflow_init(void)
/**
* Initialize this module.
*
*
* Carves out memp_memory into linked lists for each pool-type.
*/
void
...
...
@@ -397,7 +397,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
{
struct
memp
*
memp
;
SYS_ARCH_DECL_PROTECT
(
old_level
);
LWIP_ERROR
(
"memp_malloc: type < MEMP_MAX"
,
(
type
<
MEMP_MAX
),
return
NULL
;);
SYS_ARCH_PROTECT
(
old_level
);
...
...
@@ -406,7 +406,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
#endif
/* MEMP_OVERFLOW_CHECK >= 2 */
memp
=
memp_tab
[
type
];
if
(
memp
!=
NULL
)
{
memp_tab
[
type
]
=
memp
->
next
;
#if MEMP_OVERFLOW_CHECK
...
...
@@ -458,9 +458,9 @@ memp_free(memp_t type, void *mem)
#endif
/* MEMP_OVERFLOW_CHECK >= 2 */
#endif
/* MEMP_OVERFLOW_CHECK */
MEMP_STATS_DEC
(
used
,
type
);
memp
->
next
=
memp_tab
[
type
];
MEMP_STATS_DEC
(
used
,
type
);
memp
->
next
=
memp_tab
[
type
];
memp_tab
[
type
]
=
memp
;
#if MEMP_SANITY_CHECK
...
...
app/lwip/core/netif.c
View file @
d77666c0
...
...
@@ -64,13 +64,13 @@
#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
#else
#define NETIF_STATUS_CALLBACK(n)
#endif
/* LWIP_NETIF_STATUS_CALLBACK */
#endif
/* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0)
#else
#define NETIF_LINK_CALLBACK(n)
#endif
/* LWIP_NETIF_LINK_CALLBACK */
#endif
/* LWIP_NETIF_LINK_CALLBACK */
struct
netif
*
netif_list
;
struct
netif
*
netif_default
;
...
...
@@ -441,17 +441,17 @@ netif_set_default(struct netif *netif)
/**
* Bring an interface up, available for processing
* traffic.
*
*
* @note: Enabling DHCP on a down interface will make it come
* up once configured.
*
*
* @see dhcp_start()
*/
*/
void
netif_set_up
(
struct
netif
*
netif
)
{
if
(
!
(
netif
->
flags
&
NETIF_FLAG_UP
))
{
netif
->
flags
|=
NETIF_FLAG_UP
;
#if LWIP_SNMP
snmp_get_sysuptime
(
&
netif
->
ts
);
#endif
/* LWIP_SNMP */
...
...
@@ -460,7 +460,7 @@ void netif_set_up(struct netif *netif)
if
(
netif
->
flags
&
NETIF_FLAG_LINK_UP
)
{
#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
))
{
etharp_gratuitous
(
netif
);
}
...
...
@@ -481,12 +481,12 @@ void netif_set_up(struct netif *netif)
*
* @note: Enabling DHCP on a down interface will make it come
* up once configured.
*
*
* @see dhcp_start()
*/
*/
void
netif_set_down
(
struct
netif
*
netif
)
{
if
(
netif
==
NULL
)
{
if
(
netif
==
NULL
)
{
return
;
}
...
...
@@ -539,7 +539,7 @@ void netif_set_link_up(struct netif *netif )
if
(
netif
->
flags
&
NETIF_FLAG_UP
)
{
#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
)
{
etharp_gratuitous
(
netif
);
}
...
...
app/lwip/core/pbuf.c
View file @
d77666c0
...
...
@@ -12,13 +12,13 @@
*
* Multiple packets may be queued, also using this singly linked list.
* This is called a "packet queue".
*
*
* So, a packet queue consists of one or more pbuf chains, each of
* which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE
* NOT SUPPORTED!!! Use helper structs to queue multiple packets.
*
*
* 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
* ->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)
if
((
header_size_increment
==
0
)
||
(
p
==
NULL
))
{
return
0
;
}
if
(
header_size_increment
<
0
){
increment_magnitude
=
-
header_size_increment
;
/* 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)
/* Can't assert these as some callers speculatively call
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 */
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);
/* Check that we aren't going to move off the beginning of the 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)
*
* Assuming existing chains a->b->c with the following reference
* counts, calling pbuf_free(a) results in:
*
*
* 1->2->3 becomes ...1->3
* 3->3->3 becomes 2->3->3
* 1->1->2 becomes ......1
...
...
@@ -701,7 +701,7 @@ pbuf_free(struct pbuf *p)
LWIP_ASSERT
(
"pbuf_free: sane type"
,
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
||
p
->
type
==
PBUF_ESF_RX
#endif //EBUF_LWIP
...
...
@@ -812,10 +812,10 @@ pbuf_ref(struct pbuf *p)
/**
* Concatenate two pbufs (each may be a pbuf chain) and take over
* the caller's reference of the tail pbuf.
*
*
* @note The caller MAY NOT reference the tail pbuf afterwards.
* Use pbuf_chain() for that purpose.
*
*
* @see pbuf_chain()
*/
...
...
@@ -846,10 +846,10 @@ pbuf_cat(struct pbuf *h, struct pbuf *t)
/**
* Chain two pbufs (or pbuf chains) together.
*
*
* The caller MUST call pbuf_free(t) once it has stopped
* using it. Use pbuf_cat() instead if you no longer use t.
*
*
* @param h head pbuf (chain)
* @param t tail pbuf (chain)
* @note The pbufs MUST belong to the same packet.
...
...
@@ -987,7 +987,7 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
*
* @param buf the pbuf from which to copy data
* @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
* @param offset offset into the packet buffer from where to begin copying len bytes
* @return the number of bytes copied, or 0 on failure
...
...
app/lwip/core/raw.c
View file @
d77666c0
...
...
@@ -172,14 +172,14 @@ raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
/**
* 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
* - 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.
* - not free the packet, and return zero. The packet will be matched
* against further PCBs and/or forwarded to another protocol layers.
*
*
* @return non-zero if the packet was free()d, zero if the packet remains
* available for others.
*/
...
...
@@ -210,9 +210,9 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
struct
netif
*
netif
;
ip_addr_t
*
src_ip
;
struct
pbuf
*
q
;
/* q will be sent down the stack */
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? */
if
(
pbuf_header
(
p
,
IP_HLEN
))
{
/* allocate header in new pbuf */
...
...
app/lwip/core/stats.c
View file @
d77666c0
...
...
@@ -6,9 +6,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 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
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
@@ -72,18 +72,18 @@ void
stats_display_proto
(
struct
stats_proto
*
proto
,
char
*
name
)
{
LWIP_PLATFORM_DIAG
((
"
\n
%s
\n\t
"
,
name
));
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
((
"fw: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
fw
));
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
((
"lenerr: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
lenerr
));
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
((
"proterr: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
proterr
));
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
((
"cachehit: %"
STAT_COUNTER_F
"
\n
"
,
proto
->
cachehit
));
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
((
"fw: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
fw
));
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
((
"lenerr: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
lenerr
));
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
((
"proterr: %"
STAT_COUNTER_F
"
\n\t
"
,
proto
->
proterr
));
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
((
"cachehit: %"
STAT_COUNTER_F
"
\n
"
,
proto
->
cachehit
));
}
#if IGMP_STATS
...
...
@@ -91,20 +91,20 @@ void
stats_display_igmp
(
struct
stats_igmp
*
igmp
)
{
LWIP_PLATFORM_DIAG
((
"
\n
IGMP
\n\t
"
));
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
((
"drop: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
drop
));
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
((
"memerr: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
memerr
));
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
((
"xmit: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
xmit
));
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
((
"chkerr: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
chkerr
));
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
((
"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_group: %"
STAT_COUNTER_F
"
\n
"
,
igmp
->
rx_group
));
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
((
"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_report: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
tx_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_leave: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
tx_leave
));
LWIP_PLATFORM_DIAG
((
"tx_report: %"
STAT_COUNTER_F
"
\n\t
"
,
igmp
->
tx_report
));
}
#endif
/* IGMP_STATS */
...
...
@@ -113,9 +113,9 @@ void
stats_display_mem
(
struct
stats_mem
*
mem
,
char
*
name
)
{
LWIP_PLATFORM_DIAG
((
"
\n
MEM %s
\n\t
"
,
name
));
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
((
"max: %"
U32_F
"
\n\t
"
,
(
u32_t
)
mem
->
max
));
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
((
"max: %"
U32_F
"
\n\t
"
,
(
u32_t
)
mem
->
max
));
LWIP_PLATFORM_DIAG
((
"err: %"
U32_F
"
\n
"
,
(
u32_t
)
mem
->
err
));
}
...
...
@@ -139,15 +139,15 @@ void
stats_display_sys
(
struct
stats_sys
*
sys
)
{
LWIP_PLATFORM_DIAG
((
"
\n
SYS
\n\t
"
));
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.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.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
((
"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.err: %"
U32_F
"
\n\t
"
,
(
u32_t
)
sys
->
mbox
.
err
));
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.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.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
((
"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.err: %"
U32_F
"
\n\t
"
,
(
u32_t
)
sys
->
mbox
.
err
));
}
#endif
/* SYS_STATS */
...
...
app/lwip/core/sys_arch.c
View file @
d77666c0
/*
* copyright (c) 2010 - 2011 espressif system
*/
#include "c_types.h"
#include "ets_sys.h"
#include "osapi.h"
#include "os_type.h"
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "eagle_soc.h"
/*
* copyright (c) 2010 - 2011 espressif system
*/
#include "c_types.h"
#include "ets_sys.h"
#include "osapi.h"
#include "os_type.h"
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "eagle_soc.h"
app/lwip/core/tcp.c
View file @
d77666c0
...
...
@@ -10,9 +10,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -21,21 +21,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 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
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
@@ -61,17 +61,17 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__;
#if TCP_DEBUG
const
char
tcp_state_str_rodata
[][
12
]
ICACHE_RODATA_ATTR
=
{
"CLOSED"
,
"LISTEN"
,
"SYN_SENT"
,
"SYN_RCVD"
,
"ESTABLISHED"
,
"FIN_WAIT_1"
,
"FIN_WAIT_2"
,
"CLOSE_WAIT"
,
"CLOSING"
,
"LAST_ACK"
,
"TIME_WAIT"
"CLOSED"
,
"LISTEN"
,
"SYN_SENT"
,
"SYN_RCVD"
,
"ESTABLISHED"
,
"FIN_WAIT_1"
,
"FIN_WAIT_2"
,
"CLOSE_WAIT"
,
"CLOSING"
,
"LAST_ACK"
,
"TIME_WAIT"
};
char
tcp_state_str
[
12
];
...
...
@@ -105,7 +105,7 @@ struct tcp_pcb ** const tcp_pcb_lists[] ICACHE_RODATA_ATTR = {&tcp_listen_pcbs.p
/** Only used for temporary storage. */
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
u16_t
tcp_new_port
(
void
);
//����µ�tcp���ض˿�
...
...
@@ -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
* 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)
* 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
* been freed, and so any remaining handles are bogus. */
/*��CLOSED״̬�¹ر�һ��pcb�ƺ��Ǵ���ģ�
*������ˣ�һ�������״̬�·����˶��һ�û��ʹ��,�û���ҪһЩ�취���ͷ���
*����һ���Ѿ����رյ�pcb��tcp_close(),(��2��)����һ���Ѿ���ʹ����֮����CLOSE״̬�Ǵ����
*������Щ����±��ͷŵ�pcb�Dz�����ڵ�,��ˣ��κ�ʣ��ľ���Ǽٵ�
*/
err
=
ERR_OK
;
//�趨����ֵ
/*��CLOSED״̬�¹ر�һ��pcb�ƺ��Ǵ���ģ�
*������ˣ�һ�������״̬�·����˶��һ�û��ʹ��,�û���ҪһЩ�취���ͷ���
*����һ���Ѿ����رյ�pcb��tcp_close(),(��2��)����һ���Ѿ���ʹ����֮����CLOSE״̬�Ǵ����
*������Щ����±��ͷŵ�pcb�Dz�����ڵ�,��ˣ��κ�ʣ��ľ���Ǽٵ�
*/
err
=
ERR_OK
;
//�趨����ֵ
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��Ӧ�ĵ�Ԫֵ,�ͷ��ڴ�
pcb
=
NULL
;
break
;
case
LISTEN
:
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��Ԫֵ ,�ͷ��ڴ�
pcb
=
NULL
;
break
;
...
...
@@ -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
* another err_t if closing failed and pcb is not freed
*/
/*
*ͨ��PCB�ر���������
*�����е�pcbӦ�ñ��ͷŵģ�Ҳ����ԶҲ���ᱻʹ����
*���û�����ӻ�����Ҳû�б�����,���ӵ�pcbӦ�ñ��ͷŵ�
*���һ�����ӱ�����(����SYN�Ѿ������ջ�����һ���ر��е�״̬)
*���ӱ��ر��ˣ�����������һ�����ڹرյ�״̬
*pcb�Զ���tcp_slowtmr()�ͷ�,�����������Dz���ȫ��
*/
/*
*ͨ��PCB�ر���������
*�����е�pcbӦ�ñ��ͷŵģ�Ҳ����ԶҲ���ᱻʹ����
*���û�����ӻ�����Ҳû�б�����,���ӵ�pcbӦ�ñ��ͷŵ�
*���һ�����ӱ�����(����SYN�Ѿ������ջ�����һ���ر��е�״̬)
*���ӱ��ر��ˣ�����������һ�����ڹرյ�״̬
*pcb�Զ���tcp_slowtmr()�ͷ�,�����������Dz���ȫ��
*/
err_t
tcp_close
(
struct
tcp_pcb
*
pcb
)
{
...
...
@@ -341,7 +341,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
u32_t
seqno
,
ackno
;
u16_t
remote_port
,
local_port
;
ip_addr_t
remote_ip
,
local_ip
;
#if LWIP_CALLBACK_API
#if LWIP_CALLBACK_API
tcp_err_fn
errf
;
#endif
/* LWIP_CALLBACK_API */
void
*
errf_arg
;
...
...
@@ -373,7 +373,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
if
(
pcb
->
unsent
!=
NULL
)
{
tcp_segs_free
(
pcb
->
unsent
);
}
#if TCP_QUEUE_OOSEQ
#if TCP_QUEUE_OOSEQ
if
(
pcb
->
ooseq
!=
NULL
)
{
tcp_segs_free
(
pcb
->
ooseq
);
}
...
...
@@ -555,7 +555,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
return
(
struct
tcp_pcb
*
)
lpcb
;
}
/**
/**
* Update the state that tracks the available window space to advertise.
*
* Returns how much extra window would be advertised if we sent an
...
...
@@ -636,7 +636,7 @@ tcp_new_port(void)
#define TCP_LOCAL_PORT_RANGE_END 0x7fff
#endif
static
u16_t
port
=
TCP_LOCAL_PORT_RANGE_START
;
again:
// if (++port >= TCP_LOCAL_PORT_RANGE_END) {
// port = TCP_LOCAL_PORT_RANGE_START;
...
...
@@ -646,7 +646,7 @@ tcp_new_port(void)
if
(
port
<
TCP_LOCAL_PORT_RANGE_START
)
port
+=
TCP_LOCAL_PORT_RANGE_START
;
/* 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
)
{
if
(
pcb
->
local_port
==
port
)
{
goto
again
;
...
...
@@ -743,7 +743,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
pcb
->
ssthresh
=
pcb
->
mss
*
10
;
#if LWIP_CALLBACK_API
pcb
->
connected
=
connected
;
//ע��connected�ص�����
#else
/* LWIP_CALLBACK_API */
#else
/* LWIP_CALLBACK_API */
LWIP_UNUSED_ARG
(
connected
);
#endif
/* LWIP_CALLBACK_API */
...
...
@@ -849,7 +849,7 @@ tcp_slowtmr(void)
LWIP_DEBUGF
(
TCP_CWND_DEBUG
,
(
"tcp_slowtmr: cwnd %"
U16_F
" ssthresh %"
U16_F
"
\n
"
,
pcb
->
cwnd
,
pcb
->
ssthresh
));
/* The following needs to be called AFTER cwnd is set to one
mss - STJ */
tcp_rexmit_rto
(
pcb
);
...
...
@@ -873,7 +873,7 @@ tcp_slowtmr(void)
if
((
u32_t
)(
tcp_ticks
-
pcb
->
tmr
)
>
(
pcb
->
keep_idle
+
(
pcb
->
keep_cnt
*
pcb
->
keep_intvl
))
/
TCP_SLOW_INTERVAL
)
#else
#else
if
((
u32_t
)(
tcp_ticks
-
pcb
->
tmr
)
>
(
pcb
->
keep_idle
+
TCP_MAXIDLE
)
/
TCP_SLOW_INTERVAL
)
#endif
/* LWIP_TCP_KEEPALIVE */
...
...
@@ -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
"
,
ip4_addr1_16
(
&
pcb
->
remote_ip
),
ip4_addr2_16
(
&
pcb
->
remote_ip
),
ip4_addr3_16
(
&
pcb
->
remote_ip
),
ip4_addr4_16
(
&
pcb
->
remote_ip
)));
++
pcb_remove
;
++
pcb_reset
;
}
#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
)
/
TCP_SLOW_INTERVAL
)
#else
else
if
((
u32_t
)(
tcp_ticks
-
pcb
->
tmr
)
>
(
pcb
->
keep_idle
+
pcb
->
keep_cnt_sent
*
TCP_KEEPINTVL_DEFAULT
)
else
if
((
u32_t
)(
tcp_ticks
-
pcb
->
tmr
)
>
(
pcb
->
keep_idle
+
pcb
->
keep_cnt_sent
*
TCP_KEEPINTVL_DEFAULT
)
/
TCP_SLOW_INTERVAL
)
#endif
/* LWIP_TCP_KEEPALIVE */
{
...
...
@@ -942,12 +942,12 @@ tcp_slowtmr(void)
LWIP_ASSERT
(
"tcp_slowtmr: first pcb == tcp_active_pcbs"
,
tcp_active_pcbs
==
pcb
);
tcp_active_pcbs
=
pcb
->
next
;
}
if
(
pcb_reset
)
{
tcp_rst
(
pcb
->
snd_nxt
,
pcb
->
rcv_nxt
,
&
pcb
->
local_ip
,
&
pcb
->
remote_ip
,
pcb
->
local_port
,
pcb
->
remote_port
);
}
TCP_EVENT_ERR
(
pcb
->
errf
,
pcb
->
callback_arg
,
ERR_ABRT
);
pcb2
=
pcb
;
pcb
=
pcb
->
next
;
...
...
@@ -971,7 +971,7 @@ tcp_slowtmr(void)
}
}
/* Steps through all of the TIME-WAIT PCBs. */
prev
=
NULL
;
pcb
=
tcp_tw_pcbs
;
...
...
@@ -983,7 +983,7 @@ tcp_slowtmr(void)
if
((
u32_t
)(
tcp_ticks
-
pcb
->
tmr
)
>
2
*
TCP_MSL
/
TCP_SLOW_INTERVAL
)
{
++
pcb_remove
;
}
/* If the PCB should be removed, do it. */
...
...
@@ -1101,7 +1101,7 @@ tcp_setprio(struct tcp_pcb *pcb, u8_t prio)
*
* @param seg the old tcp_seg
* @return a copy of seg
*/
*/
struct
tcp_seg
*
tcp_seg_copy
(
struct
tcp_seg
*
seg
)
{
...
...
@@ -1111,7 +1111,7 @@ tcp_seg_copy(struct tcp_seg *seg)
if
(
cseg
==
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
);
return
cseg
;
}
...
...
@@ -1150,7 +1150,7 @@ tcp_kill_prio(u8_t prio)
mprio
=
TCP_PRIO_MAX
;
/* We kill the oldest active connection that has lower priority than prio. */
inactivity
=
0
;
inactive
=
NULL
;
...
...
@@ -1207,7 +1207,7 @@ tcp_alloc(u8_t prio)
{
struct
tcp_pcb
*
pcb
;
u32_t
iss
;
pcb
=
(
struct
tcp_pcb
*
)
memp_malloc
(
MEMP_TCP_PCB
);
//�����ڴ�ؿռ�
if
(
pcb
==
NULL
)
{
//os_printf("tcp_pcb memory is fail\n");
...
...
@@ -1253,18 +1253,18 @@ tcp_alloc(u8_t prio)
pcb
->
snd_wl2
=
iss
;
//��ʼ�����ʹ��ڸ����ֶ�
pcb
->
snd_nxt
=
iss
;
pcb
->
lastack
=
iss
;
pcb
->
snd_lbb
=
iss
;
pcb
->
snd_lbb
=
iss
;
pcb
->
tmr
=
tcp_ticks
;
//��¼���ƿ鴴��ϵͳʱ��
pcb
->
polltmr
=
0
;
//����������¼���ʱ��
#if LWIP_CALLBACK_API
pcb
->
recv
=
tcp_recv_null
;
//ע�������ݵ�Ĭ���ϲ㺯��
#endif
/* LWIP_CALLBACK_API */
#endif
/* LWIP_CALLBACK_API */
/* Init KEEPALIVE timer */
pcb
->
keep_idle
=
TCP_KEEPIDLE_DEFAULT
;
#if LWIP_TCP_KEEPALIVE
pcb
->
keep_intvl
=
TCP_KEEPINTVL_DEFAULT
;
pcb
->
keep_cnt
=
TCP_KEEPCNT_DEFAULT
;
...
...
@@ -1300,10 +1300,10 @@ tcp_new(void)
* ���ֶν���Ϊ����ݸ��������
* @param pcb tcp_pcb to set the callback argument
* @param arg void pointer argument to pass to callback functions
*/
*/
void
tcp_arg
(
struct
tcp_pcb
*
pcb
,
void
*
arg
)
{
{
pcb
->
callback_arg
=
arg
;
}
#if LWIP_CALLBACK_API
...
...
@@ -1314,7 +1314,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg)
*����ƿ��recv�ֶ�ע�ắ���յ����ʱ�ص�
* @param pcb tcp_pcb to set the recv callback
* @param recv callback function to call for this pcb when data is received
*/
*/
void
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 �ֶ�ע�ắ����ݷ��ͳɹ���ص�
* @param pcb tcp_pcb to set the sent callback
* @param sent callback function to call for this pcb when data is successfully sent
*/
*/
void
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 err callback function to call for this pcb when a fatal error
* has occured on the connection
*/
*/
void
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 accept callback function to call for this pcb when LISTENing
* connection has been connected to another host
*/
*/
void
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
* timer interval, which is called twice a second.
*����ƿ��POLL�ֶ�ע�ắ��ú��������Ա�����
*/
*/
void
tcp_poll
(
struct
tcp_pcb
*
pcb
,
tcp_poll_fn
poll
,
u8_t
interval
)
{
#if LWIP_CALLBACK_API
pcb
->
poll
=
poll
;
#else
/* LWIP_CALLBACK_API */
#else
/* LWIP_CALLBACK_API */
LWIP_UNUSED_ARG
(
poll
);
#endif
/* LWIP_CALLBACK_API */
#endif
/* LWIP_CALLBACK_API */
pcb
->
pollinterval
=
interval
;
}
...
...
@@ -1461,7 +1461,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
TCP_RMV
(
pcblist
,
pcb
);
tcp_pcb_purge
(
pcb
);
/* if there is an outstanding delayed ACKs, send it */
if
(
pcb
->
state
!=
TIME_WAIT
&&
pcb
->
state
!=
LISTEN
&&
...
...
@@ -1492,7 +1492,7 @@ u32_t
tcp_next_iss
(
void
)
{
static
u32_t
iss
=
6510
;
again:
iss
+=
tcp_ticks
;
/* XXX */
if
(
iss
==
0
)
...
...
@@ -1632,21 +1632,21 @@ tcp_debug_print_pcbs(void)
pcb
->
local_port
,
pcb
->
remote_port
,
pcb
->
snd_nxt
,
pcb
->
rcv_nxt
));
tcp_debug_print_state
(
pcb
->
state
);
}
}
LWIP_DEBUGF
(
TCP_DEBUG
,
(
"Listen PCB states:
\n
"
));
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
" "
,
pcb
->
local_port
,
pcb
->
remote_port
,
pcb
->
snd_nxt
,
pcb
->
rcv_nxt
));
tcp_debug_print_state
(
pcb
->
state
);
}
}
LWIP_DEBUGF
(
TCP_DEBUG
,
(
"TIME-WAIT PCB states:
\n
"
));
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
" "
,
pcb
->
local_port
,
pcb
->
remote_port
,
pcb
->
snd_nxt
,
pcb
->
rcv_nxt
));
tcp_debug_print_state
(
pcb
->
state
);
}
}
}
/**
...
...
app/lwip/core/tcp_in.c
View file @
d77666c0
...
...
@@ -6,7 +6,7 @@
*
* These functions are generally called in the order (ip_input() ->)
* tcp_input() -> * tcp_process() -> tcp_receive() (-> application).
*
*
*/
/*
...
...
@@ -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 inp network interface on which this segment was received
*/
/**
* TCP��ʼ�����봦�?��֤��TCPͷ���������IP�����
* @����p:������յ�TCP��(ָ��IPͷ�ĸ���)
* @����inp:���նε�����ӿ�
*/
/**
* TCP��ʼ�����봦�?��֤��TCPͷ���������IP�����
* @����p:������յ�TCP��(ָ��IPͷ�ĸ���)
* @����inp:���նε�����ӿ�
*/
void
tcp_input
(
struct
pbuf
*
p
,
struct
netif
*
inp
)
{
...
...
@@ -112,15 +112,15 @@ tcp_input(struct pbuf *p, struct netif *inp)
PERF_START
;
TCP_STATS_INC
(
tcp
.
recv
);
//״̬��1
TCP_STATS_INC
(
tcp
.
recv
);
//״̬��1
snmp_inc_tcpinsegs
();
//tcp����μ�1
iphdr
=
(
struct
ip_hdr
*
)
p
->
payload
;
// pointer to the actual data in the buffer
/*
*��ͷ����(IHL)��4λ��IPЭ���ͷ�ij��ȣ�ָ��IPv4Э���ͷ���ȵ��ֽ������ٸ�32λ��
*����IPv4�İ�ͷ���ܰ�ɱ������Ŀ�ѡ ���������ֶο�������ȷ��IPv4��ݱ�����ݲ��ֵ�ƫ������
*IPv4��ͷ����С������20���ֽڣ����IHL����ֶε���Сֵ��ʮ���Ʊ�ʾ����5 (5x4 = 20�ֽ�)��
*����˵�����ʾ�İ�ͷ�����ֽ�����4�ֽڵı���
/*
*��ͷ����(IHL)��4λ��IPЭ���ͷ�ij��ȣ�ָ��IPv4Э���ͷ���ȵ��ֽ������ٸ�32λ��
*����IPv4�İ�ͷ���ܰ�ɱ������Ŀ�ѡ ���������ֶο�������ȷ��IPv4��ݱ�����ݲ��ֵ�ƫ������
*IPv4��ͷ����С������20���ֽڣ����IHL����ֶε���Сֵ��ʮ���Ʊ�ʾ����5 (5x4 = 20�ֽ�)��
*����˵�����ʾ�İ�ͷ�����ֽ�����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)
TCP_STATS_INC
(
tcp
.
lenerr
);
//���ȼ���
TCP_STATS_INC
(
tcp
.
drop
);
//��ֹ����
snmp_inc_tcpinerrs
();
pbuf_free
(
p
);
//�ͷ�buffer
pbuf_free
(
p
);
//�ͷ�buffer
return
;
}
...
...
@@ -183,23 +183,23 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* Convert fields in TCP header to host byte order. */
tcphdr
->
src
=
ntohs
(
tcphdr
->
src
);
//ת��Դ��ַ
tcphdr
->
dest
=
ntohs
(
tcphdr
->
dest
);
//ת��Ŀ�ĵ�ַ
seqno
=
tcphdr
->
seqno
=
ntohl
(
tcphdr
->
seqno
);
//ת�����к�
seqno
=
tcphdr
->
seqno
=
ntohl
(
tcphdr
->
seqno
);
//ת�����к�
ackno
=
tcphdr
->
ackno
=
ntohl
(
tcphdr
->
ackno
);
//ת��Ӧ���
tcphdr
->
wnd
=
ntohs
(
tcphdr
->
wnd
);
//ת��tcp����
flags
=
TCPH_FLAGS
(
tcphdr
);
//�õ�tcp header�ı�־
/*
*��־��3λ�����ֶΣ���
* ����λ��1λ
* ���ֶ�λ��1λ��ȡֵ��0��������ݱ��ֶΣ���1����ݱ����ֶܷΣ�
* ����λ��1λ��ȡֵ��0����ݰ����û�а�1����ݰ�����и��İ�
*/
flags
=
TCPH_FLAGS
(
tcphdr
);
//�õ�tcp header�ı�־
/*
*��־��3λ�����ֶΣ���
* ����λ��1λ
* ���ֶ�λ��1λ��ȡֵ��0��������ݱ��ֶΣ���1����ݱ����ֶܷΣ�
* ����λ��1λ��ȡֵ��0����ݰ����û�а�1����ݰ�����и��İ�
*/
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
for an active connection. ���ȣ�����Ƿ�һ��Ҫ����һ������*/
////////////////////////////////////////////////////////////////////////////////////////
prev
=
NULL
;
prev
=
NULL
;
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 != TIME-WAIT"
,
pcb
->
state
!=
TIME_WAIT
);
...
...
@@ -286,9 +286,9 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* put this listening pcb at the head of the listening list */
tcp_listen_pcbs
.
listen_pcbs
=
lpcb
;
}
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
);
return
;
}
...
...
@@ -385,7 +385,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
//PSH��־ PSH ����λ��
//��PSH=1ʱ��Ҫ���ͷ����Ϸ��÷ֶΣ�
//����շ�����Ľ����Ľ���Ӧ�ò㣬�������д��?
if
(
flags
&
TCP_PSH
)
{
recv_data
->
flags
|=
PBUF_FLAG_PUSH
;
//���bufferӦ������������
}
...
...
@@ -411,7 +411,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
if
(
pcb
->
rcv_wnd
!=
TCP_WND
)
{
pcb
->
rcv_wnd
++
;
}
TCP_EVENT_CLOSED
(
pcb
,
err
);
if
(
err
==
ERR_ABRT
)
{
goto
aborted
;
...
...
@@ -595,21 +595,21 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
static
err_t
tcp_timewait_input
(
struct
tcp_pcb
*
pcb
)
{
if
(
flags
&
TCP_RST
)
{
//RST��λ��ֱ�ӷ���
return
ERR_OK
;
}
if
(
flags
&
TCP_SYN
)
{
//��SYN������Ϣ����������ݱ���ڽ��մ����ڣ����ͷ�����RST����
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
(),
tcphdr
->
dest
,
tcphdr
->
src
);
return
ERR_OK
;
}
}
else
if
(
flags
&
TCP_FIN
)
{
//���İ�FIN������Ϣ
pcb
->
tmr
=
tcp_ticks
;
//��λ�ȴ�2MSLʱ�䣬���ƿ����µȴ�2MSL
}
...
...
@@ -648,7 +648,7 @@ tcp_process(struct tcp_pcb *pcb)
acceptable
=
1
;
}
}
else
{
if
(
TCP_SEQ_BETWEEN
(
seqno
,
pcb
->
rcv_nxt
,
if
(
TCP_SEQ_BETWEEN
(
seqno
,
pcb
->
rcv_nxt
,
pcb
->
rcv_nxt
+
pcb
->
rcv_wnd
))
{
acceptable
=
1
;
}
...
...
@@ -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 */
tcp_ack_now
(
pcb
);
return
ERR_OK
;
}
if
((
pcb
->
flags
&
TF_RXCLOSED
)
==
0
)
{
/* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */
pcb
->
tmr
=
tcp_ticks
;
...
...
@@ -939,7 +939,7 @@ tcp_receive(struct tcp_pcb *pcb)
#if TCP_WND_DEBUG
}
else
{
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 %"
U32_F
" wl1 %"
U32_F
" seqno %"
U32_F
" wl2 %"
U32_F
"
\n
"
,
pcb
->
lastack
,
ackno
,
pcb
->
snd_wl1
,
seqno
,
pcb
->
snd_wl2
));
...
...
@@ -954,12 +954,12 @@ tcp_receive(struct tcp_pcb *pcb)
* 3) the advertised window hasn't changed ���ش���û�и���
* 4) There is outstanding unacknowledged data (retransmission timer running)������ݵȴ�ȷ��
* 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:
* a) dupacks < 3: do nothing
* b) dupacks == 3: fast retransmit
* c) dupacks > 3: increase cwnd
*
*
* If it passes all five, should process as a dupack:
* a) dupacks < 3: do nothing
* b) dupacks == 3: fast retransmit
* c) dupacks > 3: increase cwnd
*
* If it only passes 1-3, should reset dupack counter (and add to
* stats, which we don't do in lwIP)
*
...
...
@@ -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֮�䣬�жϷ��ʹ��������
/* We come here when the ACK acknowledges new data. */
if
(
pcb
->
flags
&
TF_INFR
)
{
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. */
...
...
@@ -1047,7 +1047,7 @@ tcp_receive(struct tcp_pcb *pcb)
ntohl
(
pcb
->
unacked
->
tcphdr
->
seqno
)
+
TCP_TCPLEN
(
pcb
->
unacked
)
:
0
));
/* Remove segment from the unacknowledged list if the incoming
ACK acknowlegdes them.
ACK acknowlegdes them.
*�ͷ�unacked�����ϱ�ȷ�ϵı��ĶΣ�
*ֱ��unacked����Ϊ��ֹͣ*/
while
(
pcb
->
unacked
!=
NULL
&&
...
...
@@ -1068,7 +1068,7 @@ tcp_receive(struct tcp_pcb *pcb)
pcb
->
acked
--
;
}
pcb
->
snd_queuelen
-=
pbuf_clen
(
next
->
p
);
//�������������pbufs����
pcb
->
snd_queuelen
-=
pbuf_clen
(
next
->
p
);
//�������������pbufs����
tcp_seg_free
(
next
);
//�ͷ�tcp��
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)
in fact have been sent once. */
/** unsent�������Ƿ��ܱ�acknoȷ�ϵı��ĶΣ������ͷ�**/
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
))
{
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
)
+
TCP_TCPLEN
(
pcb
->
unsent
)));
next
=
pcb
->
unsent
;
//pcbδ���ͱ�־
next
=
pcb
->
unsent
;
//pcbδ���ͱ�־
pcb
->
unsent
=
pcb
->
unsent
->
next
;
//δ���͵���һ��
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
)));
...
...
@@ -1252,7 +1252,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* The sequence number must be within the window (above rcv_nxt
and below rcv_nxt + rcv_wnd) in order to be further
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,������ڽ��շ�Χ��
if
(
pcb
->
rcv_nxt
==
seqno
)
{
/* The incoming segment is the next in sequence. We check if
...
...
@@ -1261,12 +1261,12 @@ tcp_receive(struct tcp_pcb *pcb)
tcplen
=
TCP_TCPLEN
(
&
inseg
);
//���㱨�Ķγ���
if
(
tcplen
>
pcb
->
rcv_wnd
)
{
//������մ��ڴ�С��������β���ض�
LWIP_DEBUGF
(
TCP_INPUT_DEBUG
,
LWIP_DEBUGF
(
TCP_INPUT_DEBUG
,
(
"tcp_receive: other end overran receive window"
"seqno %"
U32_F
" len %"
U16_F
" right edge %"
U32_F
"
\n
"
,
seqno
,
tcplen
,
pcb
->
rcv_nxt
+
pcb
->
rcv_wnd
));
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 */
TCPH_FLAGS_SET
(
inseg
.
tcphdr
,
TCPH_FLAGS
(
inseg
.
tcphdr
)
&~
TCP_FIN
);
}
...
...
@@ -1286,7 +1286,7 @@ tcp_receive(struct tcp_pcb *pcb)
- inseq overlaps with ooseq */
if
(
pcb
->
ooseq
!=
NULL
)
{
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
"
));
/* Received in-order FIN means anything that was received
* out of order must now have been received in-order, so
...
...
@@ -1394,7 +1394,7 @@ tcp_receive(struct tcp_pcb *pcb)
recv_flags
|=
TF_GOT_FIN
;
if
(
pcb
->
state
==
ESTABLISHED
)
{
/* force passive close or we can move to active close */
pcb
->
state
=
CLOSE_WAIT
;
}
}
}
pcb
->
ooseq
=
cseg
->
next
;
...
...
@@ -1507,12 +1507,12 @@ tcp_receive(struct tcp_pcb *pcb)
}
/* check if the remote side overruns our receive window */
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"
"seqno %"
U32_F
" len %"
U16_F
" right edge %"
U32_F
"
\n
"
,
seqno
,
tcplen
,
pcb
->
rcv_nxt
+
pcb
->
rcv_wnd
));
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 */
TCPH_FLAGS_SET
(
next
->
next
->
tcphdr
,
TCPH_FLAGS
(
next
->
next
->
tcphdr
)
&~
TCP_FIN
);
}
...
...
@@ -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().
* Currently, only the MSS option is supported!
...
...
@@ -1606,7 +1606,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
return
;
}
/* 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
);
if
(
flags
&
TCP_SYN
)
{
pcb
->
ts_recent
=
ntohl
(
tsval
);
...
...
app/lwip/core/tcp_out.c
View file @
d77666c0
...
...
@@ -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 */
seg
->
tcphdr
->
urgp
=
0
;
return
seg
;
}
}
/**
* 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,
* @param pcb The TCP connection that willo enqueue the pbuf.
* @param apiflags API flags given to tcp_write.
* @param first_seg true when this pbuf will be used in the first enqueued segment.
* @param
* @param
*/
#if TCP_OVERSIZE
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)
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
));
LWIP_ERROR
(
"tcp_write: arg == NULL (programmer violates API)"
,
LWIP_ERROR
(
"tcp_write: arg == NULL (programmer violates API)"
,
arg
!=
NULL
,
return
ERR_ARG
;);
err
=
tcp_write_checks
(
pcb
,
len
);
...
...
@@ -821,7 +821,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags)
return
ERR_OK
;
}
#if LWIP_TCP_TIMESTAMPS
/* Build a timestamp option (12 bytes long) at the specified options pointer)
...
...
@@ -862,7 +862,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
return
ERR_BUF
;
}
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
));
/* remove ACK flags from the PCB, as we send an empty ACK now */
pcb
->
flags
&=
~
(
TF_ACK_DELAY
|
TF_ACK_NOW
);
...
...
@@ -874,7 +874,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
if
(
pcb
->
flags
&
TF_TIMESTAMP
)
{
tcp_build_timestamp_option
(
pcb
,
(
u32_t
*
)(
tcphdr
+
1
));
}
#endif
#endif
#if CHECKSUM_GEN_TCP
tcphdr
->
chksum
=
inet_chksum_pseudo
(
p
,
&
(
pcb
->
local_ip
),
&
(
pcb
->
remote_ip
),
...
...
@@ -950,7 +950,7 @@ tcp_output(struct tcp_pcb *pcb)
", seg == NULL, ack %"
U32_F
"
\n
"
,
pcb
->
snd_wnd
,
pcb
->
cwnd
,
wnd
,
pcb
->
lastack
));
}
else
{
LWIP_DEBUGF
(
TCP_CWND_DEBUG
,
LWIP_DEBUGF
(
TCP_CWND_DEBUG
,
(
"tcp_output: snd_wnd %"
U16_F
", cwnd %"
U16_F
", wnd %"
U32_F
", effwnd %"
U32_F
", seq %"
U32_F
", ack %"
U32_F
"
\n
"
,
pcb
->
snd_wnd
,
pcb
->
cwnd
,
wnd
,
...
...
@@ -958,12 +958,12 @@ tcp_output(struct tcp_pcb *pcb)
ntohl
(
seg
->
tcphdr
->
seqno
),
pcb
->
lastack
));
}
#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
&&
ntohl
(
seg
->
tcphdr
->
seqno
)
-
pcb
->
lastack
+
seg
->
len
<=
wnd
&&
(
seg
->
p
->
ref
<
2
)
)
{
LWIP_ASSERT
(
"RST not expected here!"
,
LWIP_ASSERT
(
"RST not expected here!"
,
(
TCPH_FLAGS
(
seg
->
tcphdr
)
&
TCP_RST
)
==
0
);
/* Stop sending if the nagle algorithm would prevent it
* Don't stop:
...
...
@@ -993,7 +993,7 @@ tcp_output(struct tcp_pcb *pcb)
}
tcp_output_segment
(
seg
,
pcb
);
//���ú����ͱ��Ķ�
snd_nxt
=
ntohl
(
seg
->
tcphdr
->
seqno
)
+
TCP_TCPLEN
(
seg
);
//����snd_nxt
if
(
TCP_SEQ_LT
(
pcb
->
snd_nxt
,
snd_nxt
))
{
pcb
->
snd_nxt
=
snd_nxt
;
//����Ҫ���͵���ݱ��
...
...
@@ -1041,7 +1041,7 @@ tcp_output(struct tcp_pcb *pcb)
#endif
/* TCP_OVERSIZE */
//���ʹ��������±��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
)
{
/* prepare for persist timer */
pcb
->
persist_cnt
=
0
;
...
...
@@ -1094,7 +1094,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
}
#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*/
if
(
pcb
->
rtime
==
-
1
)
{
pcb
->
rtime
=
0
;
...
...
@@ -1362,12 +1362,12 @@ tcp_rexmit(struct tcp_pcb *pcb)
*
* @param pcb the tcp_pcb for which to retransmit the first unacked segment
*/
void
void
tcp_rexmit_fast
(
struct
tcp_pcb
*
pcb
)
{
if
(
pcb
->
unacked
!=
NULL
&&
!
(
pcb
->
flags
&
TF_INFR
))
{
/* 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
"), fast retransmit %"
U32_F
"
\n
"
,
(
u16_t
)
pcb
->
dupacks
,
pcb
->
lastack
,
...
...
@@ -1381,19 +1381,19 @@ tcp_rexmit_fast(struct tcp_pcb *pcb)
}
else
{
pcb
->
ssthresh
=
pcb
->
cwnd
/
2
;
}
/* The minimum value for ssthresh should be 2 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
" should be min 2 mss %"
U16_F
"...
\n
"
,
pcb
->
ssthresh
,
2
*
pcb
->
mss
));
pcb
->
ssthresh
=
2
*
pcb
->
mss
;
}
pcb
->
cwnd
=
pcb
->
ssthresh
+
3
*
pcb
->
mss
;
pcb
->
flags
|=
TF_INFR
;
}
}
}
...
...
@@ -1415,12 +1415,12 @@ tcp_keepalive(struct tcp_pcb *pcb)
ip4_addr1_16
(
&
pcb
->
remote_ip
),
ip4_addr2_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
));
p
=
tcp_output_alloc_header
(
pcb
,
0
,
0
,
htonl
(
pcb
->
snd_nxt
-
1
));
if
(
p
==
NULL
)
{
LWIP_DEBUGF
(
TCP_DEBUG
,
LWIP_DEBUGF
(
TCP_DEBUG
,
(
"tcp_keepalive: could not allocate memory for pbuf
\n
"
));
return
;
}
...
...
@@ -1465,15 +1465,15 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
u16_t
len
;
u8_t
is_fin
;
LWIP_DEBUGF
(
TCP_DEBUG
,
LWIP_DEBUGF
(
TCP_DEBUG
,
(
"tcp_zero_window_probe: sending ZERO WINDOW probe to %"
U16_F
".%"
U16_F
".%"
U16_F
".%"
U16_F
"
\n
"
,
ip4_addr1_16
(
&
pcb
->
remote_ip
),
ip4_addr2_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
" 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
));
seg
=
pcb
->
unacked
;
...
...
app/lwip/core/udp.c
View file @
d77666c0
...
...
@@ -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! */
if
(
src
==
DHCP_SERVER_PORT
)
{
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!
- inp->dhcp->pcb->remote == ANY or iphdr->src */
if
((
ip_addr_isany
(
&
inp
->
dhcp
->
pcb
->
remote_ip
)
||
...
...
@@ -196,7 +196,7 @@ udp_input(struct pbuf *p, struct netif *inp)
(
broadcast
)))
{
#endif
/* IP_SOF_BROADCAST_RECV */
local_match
=
1
;
if
((
uncon_pcb
==
NULL
)
&&
if
((
uncon_pcb
==
NULL
)
&&
((
pcb
->
flags
&
UDP_FLAGS_CONNECTED
)
==
0
))
{
/* the first unconnected matching PCB */
uncon_pcb
=
pcb
;
...
...
@@ -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
* be restored after the data is sent.
*
*
* @return lwIP error code (@see udp_send for possible error codes)
*
* @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,
udphdr
->
src
=
htons
(
pcb
->
local_port
);
udphdr
->
dest
=
htons
(
dst_port
);
/* in UDP, 0 checksum means 'no checksum' */
udphdr
->
chksum
=
0x0000
;
udphdr
->
chksum
=
0x0000
;
/* Multicast Loop? */
#if LWIP_IGMP
...
...
app/lwip/netif/Makefile
View file @
d77666c0
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
GEN_LIBS
=
liblwipnetif.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
GEN_LIBS
=
liblwipnetif.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
Prev
1
…
5
6
7
8
9
10
11
12
13
…
19
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment