Major stylo search/replace for "One space between keyword and opening bracket."

This commit is contained in:
likewise
2003-05-01 13:24:01 +00:00
parent 4c3f44b0d2
commit 03bc7c868b
27 changed files with 624 additions and 601 deletions

View File

@@ -61,7 +61,7 @@ lwip_chksum(void *dataptr, int len)
}
/* add up any odd byte */
if(len == 1) {
if (len == 1) {
acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8);
DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr));
} else {
@@ -69,7 +69,7 @@ lwip_chksum(void *dataptr, int len)
}
acc = (acc >> 16) + (acc & 0xffffUL);
if((acc & 0xffff0000) != 0) {
if ((acc & 0xffff0000) != 0) {
acc = (acc >> 16) + (acc & 0xffffUL);
}
@@ -97,17 +97,17 @@ inet_chksum_pseudo(struct pbuf *p,
DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", (void *) q, (void *)q->next));
acc += lwip_chksum(q->payload, q->len);
/*DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffffUL) + (acc >> 16);
}
if(q->len % 2 != 0) {
if (q->len % 2 != 0) {
swapped = 1 - swapped;
acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
}
/*DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%lx \n", acc));*/
}
if(swapped) {
if (swapped) {
acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
}
acc += (src->addr & 0xffffUL);
@@ -117,7 +117,7 @@ inet_chksum_pseudo(struct pbuf *p,
acc += (u32_t)htons((u16_t)proto);
acc += (u32_t)htons(proto_len);
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffffUL) + (acc >> 16);
}
DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%lx\n", acc));
@@ -136,7 +136,7 @@ inet_chksum(void *dataptr, u16_t len)
u32_t acc;
acc = lwip_chksum(dataptr, len);
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffff) + (acc >> 16);
}
return ~(acc & 0xffff);
@@ -153,16 +153,16 @@ inet_chksum_pbuf(struct pbuf *p)
swapped = 0;
for(q = p; q != NULL; q = q->next) {
acc += lwip_chksum(q->payload, q->len);
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffffUL) + (acc >> 16);
}
if(q->len % 2 != 0) {
if (q->len % 2 != 0) {
swapped = 1 - swapped;
acc = (acc & 0x00ffUL << 8) | (acc & 0xff00UL >> 8);
}
}
if(swapped) {
if (swapped) {
acc = ((acc & 0x00ffUL) << 8) | ((acc & 0xff00UL) >> 8);
}
return ~(acc & 0xffffUL);

View File

@@ -67,7 +67,7 @@ chksum(void *dataptr, u16_t len)
}
/* add up any odd byte */
if(len == 1) {
if (len == 1) {
acc += htons((u16_t)(*(u8_t *)dataptr) << 8);
}
@@ -93,23 +93,23 @@ inet_chksum_pseudo(struct pbuf *p,
swapped = 0;
for(q = p; q != NULL; q = q->next) {
acc += chksum(q->payload, q->len);
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffff) + (acc >> 16);
}
if(q->len % 2 != 0) {
if (q->len % 2 != 0) {
swapped = 1 - swapped;
acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
}
}
if(swapped) {
if (swapped) {
acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
}
for(i = 0; i < 8; i++) {
acc += ((u16_t *)src->addr)[i] & 0xffff;
acc += ((u16_t *)dest->addr)[i] & 0xffff;
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffff) + (acc >> 16);
}
}
@@ -117,7 +117,7 @@ inet_chksum_pseudo(struct pbuf *p,
acc += ((u16_t *)&proto_len)[0] & 0xffff;
acc += ((u16_t *)&proto_len)[1] & 0xffff;
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffff) + (acc >> 16);
}
return ~(acc & 0xffff);
@@ -151,16 +151,16 @@ inet_chksum_pbuf(struct pbuf *p)
swapped = 0;
for(q = p; q != NULL; q = q->next) {
acc += chksum(q->payload, q->len);
while(acc >> 16) {
while (acc >> 16) {
acc = (acc & 0xffff) + (acc >> 16);
}
if(q->len % 2 != 0) {
if (q->len % 2 != 0) {
swapped = 1 - swapped;
acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
}
}
if(swapped) {
if (swapped) {
acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
}
return ~(acc & 0xffff);

View File

@@ -74,9 +74,9 @@ icmp_input(struct pbuf *p, struct netif *inp)
type = *((u8_t *)p->payload);
code = *(((u8_t *)p->payload)+1);
switch(type) {
switch (type) {
case ICMP_ECHO:
if(ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
ip_addr_ismulticast(&iphdr->dest)) {
DEBUGF(ICMP_DEBUG, ("Smurf.\n"));
#ifdef ICMP_STATS
@@ -87,7 +87,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
}
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
DEBUGF(DEMO_DEBUG, ("Pong!\n"));
if(p->tot_len < sizeof(struct icmp_echo_hdr)) {
if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p);
#ifdef ICMP_STATS
@@ -98,7 +98,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
return;
}
iecho = p->payload;
if(inet_chksum_pbuf(p) != 0) {
if (inet_chksum_pbuf(p) != 0) {
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
pbuf_free(p);
#ifdef ICMP_STATS
@@ -112,7 +112,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
iphdr->dest.addr = tmpaddr.addr;
ICMPH_TYPE_SET(iecho, ICMP_ER);
/* adjust the checksum */
if(iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
iecho->chksum += htons(ICMP_ECHO << 8) + 1;
} else {
iecho->chksum += htons(ICMP_ECHO << 8);
@@ -126,7 +126,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
snmp_inc_icmpoutechoreps();
pbuf_header(p, hlen);
ip_output_if(p, &(iphdr->src), IP_HDRINCL,
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
IPH_TTL(iphdr), IP_PROTO_ICMP, inp);
break;
default:

View File

@@ -87,25 +87,25 @@ ip_lookup(void *header, struct netif *inp)
iphdr = header;
/* not IP v4? */
if(IPH_V(iphdr) != 4) {
if (IPH_V(iphdr) != 4) {
return 0;
}
/* Immediately accept/decline packets that are fragments or has
options. */
#if IP_REASSEMBLY == 0
/* if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
/* if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
return 0;
}*/
#endif /* IP_REASSEMBLY == 0 */
#if IP_OPTIONS == 0
if(IPH_HL(iphdr) != 5) {
if (IPH_HL(iphdr) != 5) {
return 0;
}
#endif /* IP_OPTIONS == 0 */
switch(IPH_PROTO(iphdr)) {
switch (IPH_PROTO(iphdr)) {
#if LWIP_UDP > 0
case IP_PROTO_UDP:
return udp_lookup(iphdr, inp);
@@ -138,7 +138,7 @@ ip_route(struct ip_addr *dest)
/* iterate through netifs */
for(netif = netif_list; netif != NULL; netif = netif->next) {
/* network mask matches? */
if(ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
/* return netif on which to forward IP packet */
return netif;
}
@@ -163,7 +163,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
PERF_START;
/* Find network interface where to forward this IP packet to. */
netif = ip_route((struct ip_addr *)&(iphdr->dest));
if(netif == NULL) {
if (netif == NULL) {
DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n",
iphdr->dest.addr));
snmp_inc_ipnoroutes();
@@ -171,7 +171,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
}
/* Do not forward packets onto the same network interface on which
they arrived. */
if(netif == inp) {
if (netif == inp) {
DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
snmp_inc_ipnoroutes();
return;
@@ -180,9 +180,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
/* decrement TTL */
IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1);
/* send ICMP if TTL == 0 */
if(IPH_TTL(iphdr) == 0) {
if (IPH_TTL(iphdr) == 0) {
/* Don't send ICMP messages in response to ICMP messages */
if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
icmp_time_exceeded(p, ICMP_TE_TTL);
snmp_inc_icmpouttimeexcds();
}
@@ -190,7 +190,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
}
/* Incrementally update the IP checksum. */
if(IPH_CHKSUM(iphdr) >= htons(0xffff - 0x100)) {
if (IPH_CHKSUM(iphdr) >= htons(0xffff - 0x100)) {
IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100) + 1);
} else {
IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100));
@@ -235,7 +235,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* identify the IP header */
iphdr = p->payload;
if(IPH_V(iphdr) != 4) {
if (IPH_V(iphdr) != 4) {
DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %d\n", IPH_V(iphdr)));
#if IP_DEBUG
ip_debug_print(p);
@@ -254,7 +254,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
iphdrlen *= 4;
/* header length exceeds first pbuf length? */
if(iphdrlen > p->len) {
if (iphdrlen > p->len) {
DEBUGF(IP_DEBUG | 2, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n",
iphdrlen, p->len));
/* free (drop) packet pbufs */
@@ -268,7 +268,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
}
/* verify checksum */
if(inet_chksum(iphdr, iphdrlen) != 0) {
if (inet_chksum(iphdr, iphdrlen) != 0) {
DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen)));
#if IP_DEBUG
@@ -297,10 +297,10 @@ ip_input(struct pbuf *p, struct netif *inp) {
iphdr->dest.addr & ~(netif->netmask.addr)));
/* interface configured? */
if(!ip_addr_isany(&(netif->ip_addr)))
if (!ip_addr_isany(&(netif->ip_addr)))
{
/* unicast to this interface address? */
if(ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
/* or broadcast matching this interface network address? */
(ip_addr_isbroadcast(&(iphdr->dest), &(netif->netmask)) &&
ip_addr_maskcmp(&(iphdr->dest), &(netif->ip_addr), &(netif->netmask))) ||
@@ -317,9 +317,9 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* Pass DHCP messages regardless of destination address. DHCP traffic is addressed
using link layer addressing (such as Ethernet MAC) so we must not filter on IP.
According to RFC 1542 section 3.1.1, referred by RFC 2131). */
if(netif == NULL) {
if (netif == NULL) {
/* remote port is DHCP server? */
if(IPH_PROTO(iphdr) == IP_PROTO_UDP) {
if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\n",
ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));
if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {
@@ -330,12 +330,12 @@ ip_input(struct pbuf *p, struct netif *inp) {
}
#endif /* LWIP_DHCP */
/* packet not for us? */
if(netif == NULL) {
if (netif == NULL) {
/* packet not for us, route or discard */
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: packet not for us.\n"));
#if IP_FORWARD
/* non-broadcast packet? */
if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) {
if (!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) {
/* try to forward IP packet on (other) interfaces */
ip_forward(p, iphdr, inp);
}
@@ -349,16 +349,16 @@ ip_input(struct pbuf *p, struct netif *inp) {
}
#if IP_REASSEMBLY
if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8));
p = ip_reass(p);
if(p == NULL) {
if (p == NULL) {
return ERR_OK;
}
iphdr = p->payload;
}
#else /* IP_REASSEMBLY */
if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
pbuf_free(p);
DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",
ntohs(IPH_OFFSET(iphdr))));
@@ -391,7 +391,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
DEBUGF(IP_DEBUG, ("ip_input: p->len %d p->tot_len %d\n", p->len, p->tot_len));
#endif /* IP_DEBUG */
switch(IPH_PROTO(iphdr)) {
switch (IPH_PROTO(iphdr)) {
#if LWIP_UDP > 0
case IP_PROTO_UDP:
snmp_inc_ipindelivers();
@@ -410,7 +410,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
break;
default:
/* send ICMP destination protocol unreachable unless is was a broadcast */
if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) &&
if (!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) &&
!ip_addr_ismulticast(&(iphdr->dest))) {
p->payload = iphdr;
icmp_dest_unreach(p, ICMP_DUR_PROTO);
@@ -439,7 +439,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
*/
/*-----------------------------------------------------------------------------------*/
err_t
ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
u8_t ttl,
u8_t proto, struct netif *netif)
{
@@ -448,8 +448,8 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
snmp_inc_ipoutrequests();
if(dest != IP_HDRINCL) {
if(pbuf_header(p, IP_HLEN)) {
if (dest != IP_HDRINCL) {
if (pbuf_header(p, IP_HLEN)) {
DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS
@@ -472,7 +472,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
IPH_ID_SET(iphdr, htons(ip_id));
++ip_id;
if(ip_addr_isany(src)) {
if (ip_addr_isany(src)) {
ip_addr_set(&(iphdr->src), &(netif->ip_addr));
} else {
ip_addr_set(&(iphdr->src), src);
@@ -516,7 +516,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
{
struct netif *netif;
if((netif = ip_route(dest)) == NULL) {
if ((netif = ip_route(dest)) == NULL) {
DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS
@@ -526,7 +526,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
return ERR_RTE;
}
return ip_output_if(p, src, dest, ttl, proto, netif);
return ip_output_if (p, src, dest, ttl, proto, netif);
}
/*-----------------------------------------------------------------------------------*/
#if IP_DEBUG

View File

@@ -94,10 +94,10 @@ static void
ip_reass_timer(void *arg)
{
(void)arg;
if(ip_reasstmr > 1) {
if (ip_reasstmr > 1) {
ip_reasstmr--;
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
} else if(ip_reasstmr == 1)
} else if (ip_reasstmr == 1)
ip_reasstmr = 0;
}

View File

@@ -58,11 +58,11 @@ icmp_input(struct pbuf *p, struct netif *inp)
type = ((char *)p->payload)[0];
switch(type) {
switch (type) {
case ICMP6_ECHO:
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
if(p->tot_len < sizeof(struct icmp_echo_hdr)) {
if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p);
@@ -74,7 +74,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
}
iecho = p->payload;
iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN);
if(inet_chksum_pbuf(p) != 0) {
if (inet_chksum_pbuf(p) != 0) {
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
#ifdef ICMP_STATS
@@ -88,7 +88,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
ip_addr_set(&(iphdr->dest), &tmpaddr);
iecho->type = ICMP6_ER;
/* adjust the checksum */
if(iecho->chksum >= htons(0xffff - (ICMP6_ECHO << 8))) {
if (iecho->chksum >= htons(0xffff - (ICMP6_ECHO << 8))) {
iecho->chksum += htons(ICMP6_ECHO << 8) + 1;
} else {
iecho->chksum += htons(ICMP6_ECHO << 8);
@@ -99,7 +99,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
#endif /* ICMP_STATS */
/* DEBUGF("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len);*/
ip_output_if(p, &(iphdr->src), IP_HDRINCL,
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
iphdr->hoplim, IP_PROTO_ICMP, inp);
break;
default:

View File

@@ -77,7 +77,7 @@ ip_route(struct ip_addr *dest)
struct netif *netif;
for(netif = netif_list; netif != NULL; netif = netif->next) {
if(ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
return netif;
}
}
@@ -99,7 +99,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
PERF_START;
if((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) {
if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) {
DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for "));
#if IP_DEBUG
@@ -110,9 +110,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
return;
}
/* Decrement TTL and send ICMP if ttl == 0. */
if(--iphdr->hoplim == 0) {
if (--iphdr->hoplim == 0) {
/* Don't send ICMP messages in response to ICMP messages */
if(iphdr->nexthdr != IP_PROTO_ICMP) {
if (iphdr->nexthdr != IP_PROTO_ICMP) {
icmp_time_exceeded(p, ICMP_TE_TTL);
}
pbuf_free(p);
@@ -174,7 +174,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
iphdr = p->payload;
if(iphdr->v != 6) {
if (iphdr->v != 6) {
DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n"));
#if IP_DEBUG
ip_debug_print(p);
@@ -196,13 +196,13 @@ ip_input(struct pbuf *p, struct netif *inp) {
ip_addr_debug_print(&(netif->ip_addr));
DEBUGF(IP_DEBUG, ("\n"));
#endif /* IP_DEBUG */
if(ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) {
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) {
break;
}
}
if(netif == NULL) {
if (netif == NULL) {
/* packet not for us, route or discard */
#ifdef IP_FORWARD
ip_forward(p, iphdr);
@@ -223,7 +223,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
pbuf_header(p, -IP_HLEN);
switch(iphdr->nexthdr) {
switch (iphdr->nexthdr) {
case IP_PROTO_UDP:
udp_input(p);
break;
@@ -258,7 +258,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
*/
/*-----------------------------------------------------------------------------------*/
err_t
ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
u8_t ttl,
u8_t proto, struct netif *netif)
{
@@ -267,7 +267,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
PERF_START;
printf("len %u tot_len %u\n", p->len, p->tot_len);
if(pbuf_header(p, IP_HLEN)) {
if (pbuf_header(p, IP_HLEN)) {
DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS
++lwip_stats.ip.err;
@@ -280,7 +280,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
iphdr = p->payload;
if(dest != IP_HDRINCL) {
if (dest != IP_HDRINCL) {
printf("!IP_HDRLINCL\n");
iphdr->hoplim = ttl;
iphdr->nexthdr = proto;
@@ -289,7 +289,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
iphdr->v = 6;
if(ip_addr_isany(src)) {
if (ip_addr_isany(src)) {
ip_addr_set(&(iphdr->src), &(netif->ip_addr));
} else {
ip_addr_set(&(iphdr->src), src);
@@ -323,7 +323,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
u8_t ttl, u8_t proto)
{
struct netif *netif;
if((netif = ip_route(dest)) == NULL) {
if ((netif = ip_route(dest)) == NULL) {
DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS
++lwip_stats.ip.rterr;
@@ -331,7 +331,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
return ERR_RTE;
}
return ip_output_if(p, src, dest, ttl, proto, netif);
return ip_output_if (p, src, dest, ttl, proto, netif);
}
/*-----------------------------------------------------------------------------------*/
#if IP_DEBUG

View File

@@ -67,7 +67,7 @@ ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
int
ip_addr_isany(struct ip_addr *addr)
{
if(addr == NULL) return 1;
if (addr == NULL) return 1;
return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0);
}

View File

@@ -87,8 +87,8 @@ plug_holes(struct mem *mem)
LWIP_ASSERT("plug_holes: mem->next <= MEM_SIZE", mem->next <= MEM_SIZE);
nmem = (struct mem *)&ram[mem->next];
if(mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) {
if(lfree == nmem) {
if (mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) {
if (lfree == nmem) {
lfree = mem;
}
mem->next = nmem->next;
@@ -97,8 +97,8 @@ plug_holes(struct mem *mem)
/* plug hole backward */
pmem = (struct mem *)&ram[mem->prev];
if(pmem != mem && pmem->used == 0) {
if(lfree == mem) {
if (pmem != mem && pmem->used == 0) {
if (lfree == mem) {
lfree = pmem;
}
pmem->next = mem->next;
@@ -224,7 +224,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
mem2->next = mem->next;
mem2->prev = ptr;
mem->next = ptr2;
if(mem2->next != MEM_SIZE) {
if (mem2->next != MEM_SIZE) {
((struct mem *)&ram[mem2->next])->prev = ptr2;
}
@@ -257,7 +257,7 @@ mem_malloc(mem_size_t size)
for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE; ptr = ((struct mem *)&ram[ptr])->next) {
mem = (struct mem *)&ram[ptr];
if(!mem->used &&
if (!mem->used &&
mem->next - (ptr + SIZEOF_STRUCT_MEM) >= size + SIZEOF_STRUCT_MEM) {
ptr2 = ptr + SIZEOF_STRUCT_MEM + size;
mem2 = (struct mem *)&ram[ptr2];
@@ -273,7 +273,7 @@ mem_malloc(mem_size_t size)
mem->used = 1;
#ifdef MEM_STATS
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
/* if(lwip_stats.mem.max < lwip_stats.mem.used) {
/* if (lwip_stats.mem.max < lwip_stats.mem.used) {
lwip_stats.mem.max = lwip_stats.mem.used;
} */
if (lwip_stats.mem.max < ptr2) {
@@ -283,7 +283,7 @@ mem_malloc(mem_size_t size)
if (mem == lfree) {
/* Find next free block after mem */
while(lfree->used && lfree != ram_end) {
while (lfree->used && lfree != ram_end) {
lfree = (struct mem *)&ram[lfree->next];
}
LWIP_ASSERT("mem_malloc: !lfree->used", !lfree->used);

View File

@@ -125,10 +125,10 @@ memp_sanity(void)
for(m = memp_tab[i]; m != NULL; m = m->next) {
c = 1;
for(n = memp_tab[i]; n != NULL; n = n->next) {
if(n == m) {
if (n == m) {
--c;
}
if(c < 0) return 0; /* LW was: abort(); */
if (c < 0) return 0; /* LW was: abort(); */
}
}
}
@@ -154,7 +154,7 @@ memp_init(void)
memp = (struct memp *)&memp_memory[0];
for(i = 0; i < MEMP_MAX; ++i) {
size = MEM_ALIGN_SIZE(memp_sizes[i] + sizeof(struct memp));
if(memp_num[i] > 0) {
if (memp_num[i] > 0) {
memp_tab[i] = memp;
m = memp;
@@ -187,12 +187,12 @@ memp_malloc(memp_t type)
memp = memp_tab[type];
if(memp != NULL) {
if (memp != NULL) {
memp_tab[type] = memp->next;
memp->next = NULL;
#ifdef MEMP_STATS
++lwip_stats.memp[type].used;
if(lwip_stats.memp[type].used > lwip_stats.memp[type].max) {
if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) {
lwip_stats.memp[type].max = lwip_stats.memp[type].used;
}
#endif /* MEMP_STATS */
@@ -238,7 +238,7 @@ memp_free(memp_t type, void *mem)
{
struct memp *memp;
if(mem == NULL) {
if (mem == NULL) {
return;
}
memp = (struct memp *)((u8_t *)mem - sizeof(struct memp));

View File

@@ -153,14 +153,14 @@ netif_find(char *name)
struct netif *netif;
u8_t num;
if(name == NULL) {
if (name == NULL) {
return NULL;
}
num = name[2] - '0';
for(netif = netif_list; netif != NULL; netif = netif->next) {
if(num == netif->num &&
if (num == netif->num &&
name[0] == netif->name[0] &&
name[1] == netif->name[1]) {
DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));

View File

@@ -134,17 +134,17 @@ pbuf_pool_alloc(void)
#if !SYS_LIGHTWEIGHT_PROT
/* Next, check the actual pbuf pool, but if the pool is locked, we
pretend to be out of buffers and return NULL. */
if(pbuf_pool_free_lock) {
if (pbuf_pool_free_lock) {
#ifdef PBUF_STATS
++lwip_stats.pbuf.alloc_locked;
#endif /* PBUF_STATS */
return NULL;
}
pbuf_pool_alloc_lock = 1;
if(!pbuf_pool_free_lock) {
if (!pbuf_pool_free_lock) {
#endif /* SYS_LIGHTWEIGHT_PROT */
p = pbuf_pool;
if(p) {
if (p) {
pbuf_pool = p->next;
}
#if !SYS_LIGHTWEIGHT_PROT
@@ -157,9 +157,9 @@ pbuf_pool_alloc(void)
#endif /* SYS_LIGHTWEIGHT_PROT */
#ifdef PBUF_STATS
if(p != NULL) {
if (p != NULL) {
++lwip_stats.pbuf.used;
if(lwip_stats.pbuf.used > lwip_stats.pbuf.max) {
if (lwip_stats.pbuf.used > lwip_stats.pbuf.max) {
lwip_stats.pbuf.max = lwip_stats.pbuf.used;
}
}
@@ -258,7 +258,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
/* remaining length to be allocated */
rem_len = length - p->len;
/* any remaining pbufs to be allocated? */
while(rem_len > 0) {
while (rem_len > 0) {
q = pbuf_pool_alloc();
if (q == NULL) {
DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n"));
@@ -346,13 +346,13 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
SYS_ARCH_PROTECT(old_level); \
PBUF_POOL_FAST_FREE(p); \
SYS_ARCH_UNPROTECT(old_level); \
} while(0)
} while (0)
#else /* SYS_LIGHTWEIGHT_PROT */
#define PBUF_POOL_FREE(p) do { \
sys_sem_wait(pbuf_pool_free_sem); \
PBUF_POOL_FAST_FREE(p); \
sys_sem_signal(pbuf_pool_free_sem); \
} while(0)
} while (0)
#endif /* SYS_LIGHTWEIGHT_PROT */
/**
@@ -632,7 +632,7 @@ pbuf_chain(struct pbuf *h, struct pbuf *t)
LWIP_ASSERT("h != NULL", h != NULL);
LWIP_ASSERT("t != NULL", t != NULL);
if(t == NULL)
if (t == NULL)
return;
/* proceed to last pbuf of chain */

View File

@@ -58,16 +58,16 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
again:
timeouts = sys_arch_timeouts();
if(!timeouts || !timeouts->next) {
if (!timeouts || !timeouts->next) {
sys_arch_mbox_fetch(mbox, msg, 0);
} else {
if(timeouts->next->time > 0) {
if (timeouts->next->time > 0) {
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
} else {
time = 0xffffffff;
}
if(time == 0xffffffff) {
if (time == 0xffffffff) {
/* If time == 0xffffffff, a timeout occured before a message could be
fetched. We should now call the timeout handler and
deallocate the memory allocated for the timeout. */
@@ -76,7 +76,7 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
h = tmptimeout->h;
arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if(h != NULL) {
if (h != NULL) {
DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg));
h(arg);
}
@@ -87,7 +87,7 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
/* If time != 0xffffffff, a message was received before the timeout
occured. The time variable is set to the number of
milliseconds we waited for the message. */
if(time <= timeouts->next->time) {
if (time <= timeouts->next->time) {
timeouts->next->time -= time;
} else {
timeouts->next->time = 0;
@@ -106,23 +106,23 @@ sys_sem_wait(sys_sem_t sem)
sys_timeout_handler h;
void *arg;
/* while(sys_arch_sem_wait(sem, 1000) == 0);
/* while (sys_arch_sem_wait(sem, 1000) == 0);
return;*/
again:
timeouts = sys_arch_timeouts();
if(!timeouts || !timeouts->next) {
if (!timeouts || !timeouts->next) {
sys_arch_sem_wait(sem, 0);
} else {
if(timeouts->next->time > 0) {
if (timeouts->next->time > 0) {
time = sys_arch_sem_wait(sem, timeouts->next->time);
} else {
time = 0xffffffff;
}
if(time == 0xffffffff) {
if (time == 0xffffffff) {
/* If time == 0xffffffff, a timeout occured before a message could be
fetched. We should now call the timeout handler and
deallocate the memory allocated for the timeout. */
@@ -131,7 +131,7 @@ sys_sem_wait(sys_sem_t sem)
h = tmptimeout->h;
arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if(h != NULL) {
if (h != NULL) {
DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg));
h(arg);
}
@@ -143,7 +143,7 @@ sys_sem_wait(sys_sem_t sem)
/* If time != 0xffffffff, a message was received before the timeout
occured. The time variable is set to the number of
milliseconds we waited for the message. */
if(time <= timeouts->next->time) {
if (time <= timeouts->next->time) {
timeouts->next->time -= time;
} else {
timeouts->next->time = 0;
@@ -160,7 +160,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
struct sys_timeout *timeout, *t;
timeout = memp_malloc(MEMP_SYS_TIMEOUT);
if(timeout == NULL) {
if (timeout == NULL) {
return;
}
timeout->next = NULL;
@@ -173,21 +173,21 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n", (void *)timeout, msecs, (void *)h, (void *)arg));
LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);
if(timeouts->next == NULL) {
if (timeouts->next == NULL) {
timeouts->next = timeout;
return;
}
if(timeouts->next->time > msecs) {
if (timeouts->next->time > msecs) {
timeouts->next->time -= msecs;
timeout->next = timeouts->next;
timeouts->next = timeout;
} else {
for(t = timeouts->next; t != NULL; t = t->next) {
timeout->time -= t->time;
if(t->next == NULL ||
if (t->next == NULL ||
t->next->time > timeout->time) {
if(t->next != NULL) {
if (t->next != NULL) {
t->next->time -= timeout->time;
}
timeout->next = t->next;

View File

@@ -109,16 +109,16 @@ void
tcp_tmr(void)
{
++tcp_timer;
if(tcp_timer == 10) {
if (tcp_timer == 10) {
tcp_timer = 0;
}
if(tcp_timer & 1) {
if (tcp_timer & 1) {
/* Call tcp_fasttmr() every 200 ms, i.e., every other timer
tcp_tmr() is called. */
tcp_fasttmr();
}
if(tcp_timer == 0 || tcp_timer == 5) {
if (tcp_timer == 0 || tcp_timer == 5) {
/* Call tcp_slowtmr() every 500 ms, i.e., every fifth timer
tcp_tmr() is called. */
tcp_slowtmr();
@@ -142,7 +142,7 @@ tcp_close(struct tcp_pcb *pcb)
tcp_debug_print_state(pcb->state);
DEBUGF(TCP_DEBUG, ("\n"));
#endif /* TCP_DEBUG */
switch(pcb->state) {
switch (pcb->state) {
case LISTEN:
err = ERR_OK;
tcp_pcb_remove((struct tcp_pcb **)&tcp_listen_pcbs, pcb);
@@ -157,19 +157,19 @@ tcp_close(struct tcp_pcb *pcb)
break;
case SYN_RCVD:
err = tcp_send_ctrl(pcb, TCP_FIN);
if(err == ERR_OK) {
if (err == ERR_OK) {
pcb->state = FIN_WAIT_1;
}
break;
case ESTABLISHED:
err = tcp_send_ctrl(pcb, TCP_FIN);
if(err == ERR_OK) {
if (err == ERR_OK) {
pcb->state = FIN_WAIT_1;
}
break;
case CLOSE_WAIT:
err = tcp_send_ctrl(pcb, TCP_FIN);
if(err == ERR_OK) {
if (err == ERR_OK) {
pcb->state = LAST_ACK;
}
break;
@@ -180,7 +180,7 @@ tcp_close(struct tcp_pcb *pcb)
break;
}
if(pcb != NULL && err == ERR_OK) {
if (pcb != NULL && err == ERR_OK) {
err = tcp_output(pcb);
}
return err;
@@ -210,7 +210,7 @@ tcp_abort(struct tcp_pcb *pcb)
/* Figure out on which TCP PCB list we are, and remove us. If we
are in an active state, call the receive function associated with
the PCB with a NULL argument, and send an RST to the remote end. */
if(pcb->state == TIME_WAIT) {
if (pcb->state == TIME_WAIT) {
tcp_pcb_remove(&tcp_tw_pcbs, pcb);
memp_free(MEMP_TCP_PCB, pcb);
} else {
@@ -225,14 +225,14 @@ tcp_abort(struct tcp_pcb *pcb)
#endif /* LWIP_CALLBACK_API */
errf_arg = pcb->callback_arg;
tcp_pcb_remove(&tcp_active_pcbs, pcb);
if(pcb->unacked != NULL) {
if (pcb->unacked != NULL) {
tcp_segs_free(pcb->unacked);
}
if(pcb->unsent != NULL) {
if (pcb->unsent != NULL) {
tcp_segs_free(pcb->unsent);
}
#if TCP_QUEUE_OOSEQ
if(pcb->ooseq != NULL) {
if (pcb->ooseq != NULL) {
tcp_segs_free(pcb->ooseq);
}
#endif /* TCP_QUEUE_OOSEQ */
@@ -257,15 +257,15 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{
struct tcp_pcb *cpcb;
if(port == 0) {
if (port == 0) {
port = tcp_new_port();
}
/* Check if the address already is in use. */
for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs;
cpcb != NULL; cpcb = cpcb->next) {
if(cpcb->local_port == port) {
if(ip_addr_isany(&(cpcb->local_ip)) ||
if (cpcb->local_port == port) {
if (ip_addr_isany(&(cpcb->local_ip)) ||
ip_addr_isany(ipaddr) ||
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
return ERR_USE;
@@ -274,15 +274,15 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
}
for(cpcb = tcp_active_pcbs;
cpcb != NULL; cpcb = cpcb->next) {
if(cpcb->local_port == port) {
if(ip_addr_isany(&(cpcb->local_ip)) ||
if (cpcb->local_port == port) {
if (ip_addr_isany(&(cpcb->local_ip)) ||
ip_addr_isany(ipaddr) ||
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
return ERR_USE;
}
}
}
if(!ip_addr_isany(ipaddr)) {
if (!ip_addr_isany(ipaddr)) {
pcb->local_ip = *ipaddr;
}
pcb->local_port = port;
@@ -314,11 +314,11 @@ tcp_listen(struct tcp_pcb *pcb)
struct tcp_pcb_listen *lpcb;
/* already listening? */
if(pcb->state == LISTEN) {
if (pcb->state == LISTEN) {
return pcb;
}
lpcb = memp_malloc(MEMP_TCP_PCB_LISTEN);
if(lpcb == NULL) {
if (lpcb == NULL) {
return NULL;
}
lpcb->callback_arg = pcb->callback_arg;
@@ -346,10 +346,10 @@ void
tcp_recved(struct tcp_pcb *pcb, u16_t len)
{
pcb->rcv_wnd += len;
if(pcb->rcv_wnd > TCP_WND) {
if (pcb->rcv_wnd > TCP_WND) {
pcb->rcv_wnd = TCP_WND;
}
if(!(pcb->flags & TF_ACK_DELAY) &&
if (!(pcb->flags & TF_ACK_DELAY) &&
!(pcb->flags & TF_ACK_NOW)) {
tcp_ack(pcb);
}
@@ -375,22 +375,22 @@ tcp_new_port(void)
static u16_t port = TCP_LOCAL_PORT_RANGE_START;
again:
if(++port > TCP_LOCAL_PORT_RANGE_END) {
if (++port > TCP_LOCAL_PORT_RANGE_END) {
port = TCP_LOCAL_PORT_RANGE_START;
}
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->local_port == port) {
if (pcb->local_port == port) {
goto again;
}
}
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->local_port == port) {
if (pcb->local_port == port) {
goto again;
}
}
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->local_port == port) {
if (pcb->local_port == port) {
goto again;
}
}
@@ -414,13 +414,13 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
u32_t iss;
DEBUGF(TCP_DEBUG, ("tcp_connect to port %u\n", port));
if(ipaddr != NULL) {
if (ipaddr != NULL) {
pcb->remote_ip = *ipaddr;
} else {
return ERR_VAL;
}
pcb->remote_port = port;
if(pcb->local_port == 0) {
if (pcb->local_port == 0) {
pcb->local_port = tcp_new_port();
}
iss = tcp_next_iss();
@@ -446,7 +446,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
(pcb->mss & 255));
ret = tcp_enqueue(pcb, NULL, 0, TCP_SYN, 0, (u8_t *)&optdata, 4);
if(ret == ERR_OK) {
if (ret == ERR_OK) {
tcp_output(pcb);
}
return ret;
@@ -508,7 +508,7 @@ tcp_slowtmr(void)
/* Reduce congestion window and ssthresh. */
eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);
pcb->ssthresh = eff_wnd >> 1;
if(pcb->ssthresh < pcb->mss) {
if (pcb->ssthresh < pcb->mss) {
pcb->ssthresh = pcb->mss * 2;
}
pcb->cwnd = pcb->mss;
@@ -518,7 +518,7 @@ tcp_slowtmr(void)
}
/* Check if this PCB has stayed too long in FIN-WAIT-2 */
if (pcb->state == FIN_WAIT_2) {
if((u32_t)(tcp_ticks - pcb->tmr) >
if ((u32_t)(tcp_ticks - pcb->tmr) >
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
@@ -529,7 +529,7 @@ tcp_slowtmr(void)
inactive for too long, will drop the data (it will eventually
be retransmitted). */
#if TCP_QUEUE_OOSEQ
if(pcb->ooseq != NULL &&
if (pcb->ooseq != NULL &&
(u32_t)tcp_ticks - pcb->tmr >=
pcb->rto * TCP_OOSEQ_TIMEOUT) {
tcp_segs_free(pcb->ooseq);
@@ -539,8 +539,8 @@ tcp_slowtmr(void)
#endif /* TCP_QUEUE_OOSEQ */
/* Check if this PCB has stayed too long in SYN-RCVD */
if(pcb->state == SYN_RCVD) {
if((u32_t)(tcp_ticks - pcb->tmr) >
if (pcb->state == SYN_RCVD) {
if ((u32_t)(tcp_ticks - pcb->tmr) >
TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n"));
@@ -549,10 +549,10 @@ tcp_slowtmr(void)
/* If the PCB should be removed, do it. */
if(pcb_remove) {
if (pcb_remove) {
tcp_pcb_purge(pcb);
/* Remove PCB from tcp_active_pcbs list. */
if(prev != NULL) {
if (prev != NULL) {
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
prev->next = pcb->next;
} else {
@@ -570,11 +570,11 @@ tcp_slowtmr(void)
/* We check if we should poll the connection. */
++pcb->polltmr;
if(pcb->polltmr >= pcb->pollinterval) {
if (pcb->polltmr >= pcb->pollinterval) {
pcb->polltmr = 0;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n"));
TCP_EVENT_POLL(pcb, err);
if(err == ERR_OK) {
if (err == ERR_OK) {
tcp_output(pcb);
}
}
@@ -588,22 +588,22 @@ tcp_slowtmr(void)
/* Steps through all of the TIME-WAIT PCBs. */
prev = NULL;
pcb = tcp_tw_pcbs;
while(pcb != NULL) {
while (pcb != NULL) {
LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
pcb_remove = 0;
/* Check if this PCB has stayed long enough in TIME-WAIT */
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;
}
/* If the PCB should be removed, do it. */
if(pcb_remove) {
if (pcb_remove) {
tcp_pcb_purge(pcb);
/* Remove PCB from tcp_tw_pcbs list. */
if(prev != NULL) {
if (prev != NULL) {
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
prev->next = pcb->next;
} else {
@@ -634,7 +634,7 @@ tcp_fasttmr(void)
/* send delayed ACKs */
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->flags & TF_ACK_DELAY) {
if (pcb->flags & TF_ACK_DELAY) {
DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n"));
tcp_ack_now(pcb);
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
@@ -655,7 +655,7 @@ tcp_segs_free(struct tcp_seg *seg)
u8_t count = 0;
struct tcp_seg *next;
again:
if(seg != NULL) {
if (seg != NULL) {
next = seg->next;
count += tcp_seg_free(seg);
seg = next;
@@ -676,8 +676,8 @@ tcp_seg_free(struct tcp_seg *seg)
{
u8_t count = 0;
if(seg != NULL) {
if(seg->p == NULL) {
if (seg != NULL) {
if (seg->p == NULL) {
memp_free(MEMP_TCP_SEG, seg);
} else {
count = pbuf_free(seg->p);
@@ -716,7 +716,7 @@ tcp_seg_copy(struct tcp_seg *seg)
struct tcp_seg *cseg;
cseg = memp_malloc(MEMP_TCP_SEG);
if(cseg == NULL) {
if (cseg == NULL) {
return NULL;
}
memcpy((char *)cseg, (const char *)seg, sizeof(struct tcp_seg));
@@ -729,9 +729,9 @@ static err_t
tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
arg = arg;
if(p != NULL) {
if (p != NULL) {
pbuf_free(p);
} else if(err == ERR_OK) {
} else if (err == ERR_OK) {
return tcp_close(pcb);
}
return ERR_OK;
@@ -753,7 +753,7 @@ tcp_kill_prio(u8_t prio)
inactivity = 0;
inactive = NULL;
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->prio <= prio &&
if (pcb->prio <= prio &&
pcb->prio <= mprio &&
(u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
inactivity = tcp_ticks - pcb->tmr;
@@ -761,7 +761,7 @@ tcp_kill_prio(u8_t prio)
mprio = pcb->prio;
}
}
if(inactive != NULL) {
if (inactive != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB 0x%p (%ld)\n",
(void *)inactive, inactivity));
tcp_abort(inactive);
@@ -778,12 +778,12 @@ tcp_kill_timewait(void)
inactivity = 0;
inactive = NULL;
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
if((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
inactivity = tcp_ticks - pcb->tmr;
inactive = pcb;
}
}
if(inactive != NULL) {
if (inactive != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB 0x%p (%ld)\n",
(void *)inactive, inactivity));
tcp_abort(inactive);
@@ -799,17 +799,17 @@ tcp_alloc(u8_t prio)
u32_t iss;
pcb = memp_malloc(MEMP_TCP_PCB);
if(pcb == NULL) {
if (pcb == NULL) {
/* Try killing oldest connection in TIME-WAIT. */
DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n"));
tcp_kill_timewait();
pcb = memp_malloc(MEMP_TCP_PCB);
if(pcb == NULL) {
if (pcb == NULL) {
tcp_kill_prio(prio);
pcb = memp_malloc(MEMP_TCP_PCB);
}
}
if(pcb != NULL) {
if (pcb != NULL) {
memset(pcb, 0, sizeof(struct tcp_pcb));
pcb->prio = TCP_PRIO_NORMAL;
pcb->snd_buf = TCP_SND_BUF;
@@ -963,21 +963,21 @@ tcp_accept(struct tcp_pcb *pcb,
void
tcp_pcb_purge(struct tcp_pcb *pcb)
{
if(pcb->state != CLOSED &&
if (pcb->state != CLOSED &&
pcb->state != TIME_WAIT &&
pcb->state != LISTEN) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n"));
#if TCP_DEBUG
if(pcb->unsent != NULL) {
if (pcb->unsent != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n"));
}
if(pcb->unacked != NULL) {
if (pcb->unacked != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n"));
}
#if TCP_QUEUE_OOSEQ /* LW */
if(pcb->ooseq != NULL) {
if (pcb->ooseq != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n"));
}
#endif
@@ -1010,7 +1010,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
tcp_pcb_purge(pcb);
/* if there is an outstanding delayed ACKs, send it */
if(pcb->state != TIME_WAIT &&
if (pcb->state != TIME_WAIT &&
pcb->state != LISTEN &&
pcb->flags & TF_ACK_DELAY) {
pcb->flags |= TF_ACK_NOW;
@@ -1073,7 +1073,7 @@ void
tcp_debug_print_state(enum tcp_state s)
{
DEBUGF(TCP_DEBUG, ("State: "));
switch(s) {
switch (s) {
case CLOSED:
DEBUGF(TCP_DEBUG, ("CLOSED\n"));
break;
@@ -1113,22 +1113,22 @@ tcp_debug_print_state(enum tcp_state s)
void
tcp_debug_print_flags(u8_t flags)
{
if(flags & TCP_FIN) {
if (flags & TCP_FIN) {
DEBUGF(TCP_DEBUG, ("FIN "));
}
if(flags & TCP_SYN) {
if (flags & TCP_SYN) {
DEBUGF(TCP_DEBUG, ("SYN "));
}
if(flags & TCP_RST) {
if (flags & TCP_RST) {
DEBUGF(TCP_DEBUG, ("RST "));
}
if(flags & TCP_PSH) {
if (flags & TCP_PSH) {
DEBUGF(TCP_DEBUG, ("PSH "));
}
if(flags & TCP_ACK) {
if (flags & TCP_ACK) {
DEBUGF(TCP_DEBUG, ("ACK "));
}
if(flags & TCP_URG) {
if (flags & TCP_URG) {
DEBUGF(TCP_DEBUG, ("URG "));
}
}

View File

@@ -125,14 +125,14 @@ tcp_input(struct pbuf *p, struct netif *inp)
}
/* Don't even process incoming broadcasts/multicasts. */
if(ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) ||
if (ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) ||
ip_addr_ismulticast(&(iphdr->dest))) {
pbuf_free(p);
return;
}
/* Verify TCP checksum. */
if(inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest),
IP_PROTO_TCP, p->tot_len) != 0) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n", inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
@@ -173,7 +173,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
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 != LISTEN", pcb->state != LISTEN);
if(pcb->remote_port == tcphdr->src &&
if (pcb->remote_port == tcphdr->src &&
pcb->local_port == tcphdr->dest &&
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
@@ -182,7 +182,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
lookups will be faster (we exploit locality in TCP segment
arrivals). */
LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb);
if(prev != NULL) {
if (prev != NULL) {
prev->next = pcb->next;
pcb->next = tcp_active_pcbs;
tcp_active_pcbs = pcb;
@@ -199,7 +199,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
if(pcb->remote_port == tcphdr->src &&
if (pcb->remote_port == tcphdr->src &&
pcb->local_port == tcphdr->dest &&
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
@@ -217,13 +217,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
are LISTENing for incoming connections. */
prev = NULL;
for(lpcb = tcp_listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
if((ip_addr_isany(&(lpcb->local_ip)) ||
if ((ip_addr_isany(&(lpcb->local_ip)) ||
ip_addr_cmp(&(lpcb->local_ip), &(iphdr->dest))) &&
lpcb->local_port == tcphdr->dest) {
/* Move this PCB to the front of the list so that subsequent
lookups will be faster (we exploit locality in TCP segment
arrivals). */
if(prev != NULL) {
if (prev != NULL) {
((struct tcp_pcb_listen *)prev)->next = lpcb->next;
/* our successor is the remainder of the listening list */
lpcb->next = tcp_listen_pcbs;
@@ -247,7 +247,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
#endif /* TCP_INPUT_DEBUG */
if(pcb != NULL) {
if (pcb != NULL) {
/* The incoming segment belongs to a connection. */
#if TCP_INPUT_DEBUG
#if TCP_DEBUG
@@ -270,8 +270,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
tcp_input_pcb = NULL;
/* A return value of ERR_ABRT means that tcp_abort() was called
and that the pcb has been freed. If so, we don't do anything. */
if(err != ERR_ABRT) {
if(recv_flags & TF_RESET) {
if (err != ERR_ABRT) {
if (recv_flags & TF_RESET) {
/* TF_RESET means that the connection was reset by the other
end. We then call the error callback to inform the
application that the connection is dead before we
@@ -279,7 +279,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);
tcp_pcb_remove(&tcp_active_pcbs, pcb);
memp_free(MEMP_TCP_PCB, pcb);
} else if(recv_flags & TF_CLOSED) {
} else if (recv_flags & TF_CLOSED) {
/* The connection has been closed and we will deallocate the
PCB. */
tcp_pcb_remove(&tcp_active_pcbs, pcb);
@@ -289,22 +289,22 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* If the application has registered a "sent" function to be
called when new send buffer space is available, we call it
now. */
if(pcb->acked > 0) {
if (pcb->acked > 0) {
TCP_EVENT_SENT(pcb, pcb->acked, err);
}
if(recv_data != NULL) {
if (recv_data != NULL) {
/* Notify application that data has been received. */
TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err);
}
/* If a FIN segment was received, we call the callback
function with a NULL buffer to indicate EOF. */
if(recv_flags & TF_GOT_FIN) {
if (recv_flags & TF_GOT_FIN) {
TCP_EVENT_RECV(pcb, NULL, ERR_OK, err);
}
/* If there were no errors, we try to send something out. */
if(err == ERR_OK) {
if (err == ERR_OK) {
tcp_output(pcb);
}
}
@@ -327,7 +327,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* If no matching PCB was found, send a TCP RST (reset) to the
sender. */
DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
if(!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
#ifdef TCP_STATS
++lwip_stats.tcp.proterr;
++lwip_stats.tcp.drop;
@@ -357,20 +357,20 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
/* In the LISTEN state, we check for incoming SYN segments,
creates a new PCB, and responds with a SYN|ACK. */
if(flags & TCP_ACK) {
if (flags & TCP_ACK) {
/* For incoming segments with the ACK flag set, respond with a
RST. */
DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
tcp_rst(ackno + 1, seqno + tcplen,
&(iphdr->dest), &(iphdr->src),
tcphdr->dest, tcphdr->src);
} else if(flags & TCP_SYN) {
} else if (flags & TCP_SYN) {
DEBUGF(DEMO_DEBUG, ("TCP connection request %d -> %d.\n", tcphdr->src, tcphdr->dest));
npcb = tcp_alloc(pcb->prio);
/* If a new PCB could not be created (probably due to lack of memory),
we don't do anything, but rely on the sender will retransmit the
SYN at a time when we have more memory available. */
if(npcb == NULL) {
if (npcb == NULL) {
DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));
#ifdef TCP_STATS
++lwip_stats.tcp.memerr;
@@ -420,10 +420,10 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
static err_t
tcp_timewait_input(struct tcp_pcb *pcb)
{
if(TCP_SEQ_GT(seqno + tcplen, pcb->rcv_nxt)) {
if (TCP_SEQ_GT(seqno + tcplen, pcb->rcv_nxt)) {
pcb->rcv_nxt = seqno + tcplen;
}
if(tcplen > 0) {
if (tcplen > 0) {
tcp_ack_now(pcb);
}
return tcp_output(pcb);
@@ -448,20 +448,20 @@ tcp_process(struct tcp_pcb *pcb)
err = ERR_OK;
/* Process incoming RST segments. */
if(flags & TCP_RST) {
if (flags & TCP_RST) {
/* First, determine if the reset is acceptable. */
if(pcb->state == SYN_SENT) {
if(ackno == pcb->snd_nxt) {
if (pcb->state == SYN_SENT) {
if (ackno == pcb->snd_nxt) {
acceptable = 1;
}
} else {
if(TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
TCP_SEQ_LEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
acceptable = 1;
}
}
if(acceptable) {
if (acceptable) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n"));
LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED);
recv_flags = TF_RESET;
@@ -480,11 +480,11 @@ tcp_process(struct tcp_pcb *pcb)
pcb->tmr = tcp_ticks;
/* Do different things depending on the TCP state. */
switch(pcb->state) {
switch (pcb->state) {
case SYN_SENT:
DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", ackno,
pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno)));
if(flags & (TCP_ACK | TCP_SYN) &&
if (flags & (TCP_ACK | TCP_SYN) &&
ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) {
pcb->rcv_nxt = seqno + 1;
pcb->lastack = ackno;
@@ -507,16 +507,16 @@ tcp_process(struct tcp_pcb *pcb)
}
break;
case SYN_RCVD:
if(flags & TCP_ACK &&
if (flags & TCP_ACK &&
!(flags & TCP_RST)) {
if(TCP_SEQ_LT(pcb->lastack, ackno) &&
if (TCP_SEQ_LT(pcb->lastack, ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_nxt)) {
pcb->state = ESTABLISHED;
DEBUGF(DEMO_DEBUG, ("TCP connection established %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL);
/* Call the accept function. */
TCP_EVENT_ACCEPT(pcb, ERR_OK, err);
if(err != ERR_OK) {
if (err != ERR_OK) {
/* If the accept function returns with an error, we abort
the connection. */
tcp_abort(pcb);
@@ -533,15 +533,15 @@ tcp_process(struct tcp_pcb *pcb)
/* FALLTHROUGH */
case ESTABLISHED:
tcp_receive(pcb);
if(flags & TCP_FIN) {
if (flags & TCP_FIN) {
tcp_ack_now(pcb);
pcb->state = CLOSE_WAIT;
}
break;
case FIN_WAIT_1:
tcp_receive(pcb);
if(flags & TCP_FIN) {
if(flags & TCP_ACK && ackno == pcb->snd_nxt) {
if (flags & TCP_FIN) {
if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG,
("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb);
@@ -553,13 +553,13 @@ tcp_process(struct tcp_pcb *pcb)
tcp_ack_now(pcb);
pcb->state = CLOSING;
}
} else if(flags & TCP_ACK && ackno == pcb->snd_nxt) {
} else if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
pcb->state = FIN_WAIT_2;
}
break;
case FIN_WAIT_2:
tcp_receive(pcb);
if(flags & TCP_FIN) {
if (flags & TCP_FIN) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb);
tcp_pcb_purge(pcb);
@@ -570,7 +570,7 @@ tcp_process(struct tcp_pcb *pcb)
break;
case CLOSING:
tcp_receive(pcb);
if(flags & TCP_ACK && ackno == pcb->snd_nxt) {
if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb);
tcp_pcb_purge(pcb);
@@ -581,7 +581,7 @@ tcp_process(struct tcp_pcb *pcb)
break;
case LAST_ACK:
tcp_receive(pcb);
if(flags & TCP_ACK && ackno == pcb->snd_nxt) {
if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
pcb->state = CLOSED;
recv_flags = TF_CLOSED;
@@ -619,11 +619,11 @@ tcp_receive(struct tcp_pcb *pcb)
u32_t right_wnd_edge;
if(flags & TCP_ACK) {
if (flags & TCP_ACK) {
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl1;
/* Update window. */
if(TCP_SEQ_LT(pcb->snd_wl1, seqno) ||
if (TCP_SEQ_LT(pcb->snd_wl1, seqno) ||
(pcb->snd_wl1 == seqno && TCP_SEQ_LT(pcb->snd_wl2, ackno)) ||
(pcb->snd_wl2 == ackno && tcphdr->wnd > pcb->snd_wnd)) {
pcb->snd_wnd = tcphdr->wnd;
@@ -632,7 +632,7 @@ tcp_receive(struct tcp_pcb *pcb)
DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %lu\n", pcb->snd_wnd));
#if TCP_WND_DEBUG
} else {
if(pcb->snd_wnd != tcphdr->wnd) {
if (pcb->snd_wnd != tcphdr->wnd) {
DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %lu snd_max %lu ackno %lu wl1 %lu seqno %lu wl2 %lu\n",
pcb->lastack, pcb->snd_max, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2));
}
@@ -640,13 +640,13 @@ tcp_receive(struct tcp_pcb *pcb)
}
if(pcb->lastack == ackno) {
if (pcb->lastack == ackno) {
pcb->acked = 0;
if(pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){
if (pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){
++pcb->dupacks;
if(pcb->dupacks >= 3 && pcb->unacked != NULL) {
if(!(pcb->flags & TF_INFR)) {
if (pcb->dupacks >= 3 && pcb->unacked != NULL) {
if (!(pcb->flags & TF_INFR)) {
/* This is fast retransmit. Retransmit the first unacked segment. */
DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %d (%lu), fast retransmit %lu\n",
pcb->dupacks, pcb->lastack,
@@ -662,7 +662,7 @@ tcp_receive(struct tcp_pcb *pcb)
} else {
/* Inflate the congestion window, but not if it means that
the value overflows. */
if((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
pcb->cwnd += pcb->mss;
}
}
@@ -671,14 +671,14 @@ tcp_receive(struct tcp_pcb *pcb)
DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n",
pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge));
}
} else if(TCP_SEQ_LT(pcb->lastack, ackno) &&
} else if (TCP_SEQ_LT(pcb->lastack, ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_max)) {
/* We come here when the ACK acknowledges new data. */
/* Reset the "IN Fast Retransmit" flag, since we are no longer
in fast retransmit. Also reset the congestion window to the
slow start threshold. */
if(pcb->flags & TF_INFR) {
if (pcb->flags & TF_INFR) {
pcb->flags &= ~TF_INFR;
pcb->cwnd = pcb->ssthresh;
}
@@ -699,15 +699,15 @@ tcp_receive(struct tcp_pcb *pcb)
/* Update the congestion control variables (cwnd and
ssthresh). */
if(pcb->state >= ESTABLISHED) {
if(pcb->cwnd < pcb->ssthresh) {
if((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
if (pcb->state >= ESTABLISHED) {
if (pcb->cwnd < pcb->ssthresh) {
if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
pcb->cwnd += pcb->mss;
}
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd));
} else {
u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd);
if(new_cwnd > pcb->cwnd) {
if (new_cwnd > pcb->cwnd) {
pcb->cwnd = new_cwnd;
}
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd));
@@ -722,7 +722,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* Remove segment from the unacknowledged list if the incoming
ACK acknowlegdes them. */
while(pcb->unacked != NULL &&
while (pcb->unacked != NULL &&
TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) +
TCP_TCPLEN(pcb->unacked), ackno)) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unacked\n",
@@ -738,7 +738,7 @@ tcp_receive(struct tcp_pcb *pcb)
tcp_seg_free(next);
DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unacked)\n", pcb->snd_queuelen));
if(pcb->snd_queuelen != 0) {
if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL);
}
@@ -752,7 +752,7 @@ tcp_receive(struct tcp_pcb *pcb)
rationale is that lwIP puts all outstanding segments on the
->unsent list after a retransmission, so these segments may
in fact have been sent once. */
while(pcb->unsent != NULL &&
while (pcb->unsent != NULL &&
TCP_SEQ_LEQ(ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent),
ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_max)) {
@@ -767,12 +767,12 @@ tcp_receive(struct tcp_pcb *pcb)
pcb->snd_queuelen -= pbuf_clen(next->p);
tcp_seg_free(next);
DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unsent)\n", pcb->snd_queuelen));
if(pcb->snd_queuelen != 0) {
if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL);
}
if(pcb->unsent != NULL) {
if (pcb->unsent != NULL) {
pcb->snd_nxt = htonl(pcb->unsent->tcphdr->seqno);
}
}
@@ -785,7 +785,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* RTT estimation calculations. This is done by checking if the
incoming segment acknowledges the segment we use to take a
round-trip time measurement. */
if(pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) {
if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) {
m = tcp_ticks - pcb->rttest;
DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %d ticks (%d msec).\n",
@@ -794,7 +794,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* This is taken directly from VJs original code in his paper */
m = m - (pcb->sa >> 3);
pcb->sa += m;
if(m < 0) {
if (m < 0) {
m = -m;
}
m = m - (pcb->sv >> 2);
@@ -810,7 +810,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* If the incoming segment contains data, we must process it
further. */
if(tcplen > 0) {
if (tcplen > 0) {
/* This code basically does three things:
+) If the incoming segment contains data that is the next
@@ -839,8 +839,8 @@ tcp_receive(struct tcp_pcb *pcb)
this if the sequence number of the incoming segment is less
than rcv_nxt, and the sequence number plus the length of the
segment is larger than rcv_nxt. */
if(TCP_SEQ_LT(seqno, pcb->rcv_nxt)){
if(TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {
if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){
if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {
/* Trimming the first edge is done by pushing the payload
pointer in the pbuf downwards. This is somewhat tricky since
we do not want to discard the full contents of the pbuf up to
@@ -861,9 +861,9 @@ tcp_receive(struct tcp_pcb *pcb)
adjust the ->data pointer in the seg and the segment
length.*/
off = pcb->rcv_nxt - seqno;
if(inseg.p->len < off) {
if (inseg.p->len < off) {
p = inseg.p;
while(p->len < off) {
while (p->len < off) {
off -= p->len;
inseg.p->tot_len -= p->len;
p->len = 0;
@@ -889,14 +889,14 @@ 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_GEQ(seqno, pcb->rcv_nxt) &&
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
TCP_SEQ_LT(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
if(pcb->rcv_nxt == seqno) {
if (pcb->rcv_nxt == seqno) {
/* The incoming segment is the next in sequence. We check if
we have to trim the end of the segment and update rcv_nxt
and pass the data to the application. */
#if TCP_QUEUE_OOSEQ
if(pcb->ooseq != NULL &&
if (pcb->ooseq != NULL &&
TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, seqno + inseg.len)) {
/* We have to trim the second edge of the incoming
segment. */
@@ -910,7 +910,7 @@ tcp_receive(struct tcp_pcb *pcb)
pcb->rcv_nxt += tcplen;
/* Update the receiver's (our) window. */
if(pcb->rcv_wnd < tcplen) {
if (pcb->rcv_wnd < tcplen) {
pcb->rcv_wnd = 0;
} else {
pcb->rcv_wnd -= tcplen;
@@ -925,14 +925,14 @@ tcp_receive(struct tcp_pcb *pcb)
If the segment was a FIN, we set the TF_GOT_FIN flag that will
be used to indicate to the application that the remote side has
closed its end of the connection. */
if(inseg.p->tot_len > 0) {
if (inseg.p->tot_len > 0) {
recv_data = inseg.p;
/* Since this pbuf now is the responsibility of the
application, we delete our reference to it so that we won't
(mistakingly) deallocate it. */
inseg.p = NULL;
}
if(TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN."));
recv_flags = TF_GOT_FIN;
}
@@ -940,22 +940,22 @@ tcp_receive(struct tcp_pcb *pcb)
#if TCP_QUEUE_OOSEQ
/* We now check if we have segments on the ->ooseq queue that
is now in sequence. */
while(pcb->ooseq != NULL &&
while (pcb->ooseq != NULL &&
pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) {
cseg = pcb->ooseq;
seqno = pcb->ooseq->tcphdr->seqno;
pcb->rcv_nxt += TCP_TCPLEN(cseg);
if(pcb->rcv_wnd < TCP_TCPLEN(cseg)) {
if (pcb->rcv_wnd < TCP_TCPLEN(cseg)) {
pcb->rcv_wnd = 0;
} else {
pcb->rcv_wnd -= TCP_TCPLEN(cseg);
}
if(cseg->p->tot_len > 0) {
if (cseg->p->tot_len > 0) {
/* Chain this pbuf onto the pbuf that we will pass to
the application. */
if(recv_data) {
if (recv_data) {
pbuf_chain(recv_data, cseg->p);
pbuf_free(cseg->p);
} else {
@@ -963,7 +963,7 @@ tcp_receive(struct tcp_pcb *pcb)
}
cseg->p = NULL;
}
if(flags & TCP_FIN) {
if (flags & TCP_FIN) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN."));
recv_flags = TF_GOT_FIN;
}
@@ -983,7 +983,7 @@ tcp_receive(struct tcp_pcb *pcb)
tcp_ack_now(pcb);
#if TCP_QUEUE_OOSEQ
/* We queue the segment on the ->ooseq queue. */
if(pcb->ooseq == NULL) {
if (pcb->ooseq == NULL) {
pcb->ooseq = tcp_seg_copy(&inseg);
} else {
/* If the queue is not empty, we walk through the queue and
@@ -1000,19 +1000,19 @@ tcp_receive(struct tcp_pcb *pcb)
prev = NULL;
for(next = pcb->ooseq; next != NULL; next = next->next) {
if(seqno == next->tcphdr->seqno) {
if (seqno == next->tcphdr->seqno) {
/* The sequence number of the incoming segment is the
same as the sequence number of the segment on
->ooseq. We check the lengths to see which one to
discard. */
if(inseg.len > next->len) {
if (inseg.len > next->len) {
/* The incoming segment is larger than the old
segment. We replace the old segment with the new
one. */
cseg = tcp_seg_copy(&inseg);
if(cseg != NULL) {
if (cseg != NULL) {
cseg->next = next->next;
if(prev != NULL) {
if (prev != NULL) {
prev->next = cseg;
} else {
pcb->ooseq = cseg;
@@ -1026,43 +1026,43 @@ tcp_receive(struct tcp_pcb *pcb)
break;
}
} else {
if(prev == NULL) {
if(TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
if (prev == NULL) {
if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
/* The sequence number of the incoming segment is lower
than the sequence number of the first segment on the
queue. We put the incoming segment first on the
queue. */
if(TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
/* We need to trim the incoming segment. */
inseg.len = next->tcphdr->seqno - seqno;
pbuf_realloc(inseg.p, inseg.len);
}
cseg = tcp_seg_copy(&inseg);
if(cseg != NULL) {
if (cseg != NULL) {
cseg->next = next;
pcb->ooseq = cseg;
}
break;
}
} else if(TCP_SEQ_LT(prev->tcphdr->seqno, seqno) &&
} else if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) &&
TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
/* The sequence number of the incoming segment is in
between the sequence numbers of the previous and
the next segment on ->ooseq. We trim and insert the
incoming segment and trim the previous segment, if
needed. */
if(TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
/* We need to trim the incoming segment. */
inseg.len = next->tcphdr->seqno - seqno;
pbuf_realloc(inseg.p, inseg.len);
}
cseg = tcp_seg_copy(&inseg);
if(cseg != NULL) {
if (cseg != NULL) {
cseg->next = next;
prev->next = cseg;
if(TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) {
if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) {
/* We need to trim the prev segment. */
prev->len = seqno - prev->tcphdr->seqno;
pbuf_realloc(prev->p, prev->len);
@@ -1073,11 +1073,11 @@ tcp_receive(struct tcp_pcb *pcb)
/* If the "next" segment is the last segment on the
ooseq queue, we add the incoming segment to the end
of the list. */
if(next->next == NULL &&
if (next->next == NULL &&
TCP_SEQ_GT(seqno, next->tcphdr->seqno)) {
next->next = tcp_seg_copy(&inseg);
if(next->next != NULL) {
if(TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) {
if (next->next != NULL) {
if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) {
/* We need to trim the last segment. */
next->len = seqno - next->tcphdr->seqno;
pbuf_realloc(next->p, next->len);
@@ -1096,7 +1096,7 @@ tcp_receive(struct tcp_pcb *pcb)
} else {
/* Segments with length 0 is taken care of here. Segments that
fall out of the window are ACKed. */
if(TCP_SEQ_GT(pcb->rcv_nxt, seqno) ||
if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) ||
TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
tcp_ack_now(pcb);
}
@@ -1121,16 +1121,16 @@ tcp_parseopt(struct tcp_pcb *pcb)
opts = (u8_t *)tcphdr + TCP_HLEN;
/* Parse the TCP MSS option, if present. */
if((TCPH_OFFSET(tcphdr) & 0xf0) > 0x50) {
if ((TCPH_OFFSET(tcphdr) & 0xf0) > 0x50) {
for(c = 0; c < ((TCPH_OFFSET(tcphdr) >> 4) - 5) << 2 ;) {
opt = opts[c];
if(opt == 0x00) {
if (opt == 0x00) {
/* End of options. */
break;
} else if(opt == 0x01) {
} else if (opt == 0x01) {
++c;
/* NOP option. */
} else if(opt == 0x02 &&
} else if (opt == 0x02 &&
opts[c + 1] == 0x04) {
/* An MSS option with the right option length. */
mss = (opts[c + 2] << 8) | opts[c + 3];
@@ -1139,7 +1139,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
/* And we are done processing options. */
break;
} else {
if(opts[c + 1] == 0) {
if (opts[c + 1] == 0) {
/* If the length field is zero, the options are malformed
and we don't process them further. */
break;

View File

@@ -79,11 +79,11 @@ err_t
tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
{
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%u, copy=%d)\n", (void *)pcb, arg, len, copy));
if(pcb->state == SYN_SENT ||
if (pcb->state == SYN_SENT ||
pcb->state == SYN_RCVD ||
pcb->state == ESTABLISHED ||
pcb->state == CLOSE_WAIT) {
if(len > 0) {
if (len > 0) {
return tcp_enqueue(pcb, (void *)arg, len, 0, copy, NULL, 0);
}
return ERR_OK;
@@ -109,7 +109,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
left = len;
ptr = arg;
/* fail on too much data */
if(len > pcb->snd_buf) {
if (len > pcb->snd_buf) {
DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%d > snd_buf=%d)\n", len, pcb->snd_buf));
return ERR_MEM;
}
@@ -124,12 +124,12 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Check if the queue length exceeds the configured maximum queue
length. If so, we return an error. */
queuelen = pcb->snd_queuelen;
if(queuelen >= TCP_SND_QUEUELEN) {
if (queuelen >= TCP_SND_QUEUELEN) {
DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %d (max %d)\n", queuelen, TCP_SND_QUEUELEN));
goto memerr;
}
if(pcb->snd_queuelen != 0) {
if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL);
}
@@ -139,7 +139,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* First, break up the data into segments and tuck them together in
the local "queue" variable. */
while(queue == NULL || left > 0) {
while (queue == NULL || left > 0) {
/* The segment length should be the MSS if the data to be enqueued
is larger than the MSS. */
@@ -147,14 +147,14 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Allocate memory for tcp_seg, and fill in fields. */
seg = memp_malloc(MEMP_TCP_SEG);
if(seg == NULL) {
if (seg == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for tcp_seg\n"));
goto memerr;
}
seg->next = NULL;
seg->p = NULL;
if(queue == NULL) {
if (queue == NULL) {
queue = seg;
}
else {
@@ -168,19 +168,19 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
ROM or other static memory, and need not be copied. If
optdata is != NULL, we have options instead of data. */
if (optdata != NULL) {
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
goto memerr;
}
++queuelen;
seg->dataptr = seg->p->payload;
}
else if (copy) {
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) {
if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %u\n", seglen));
goto memerr;
}
++queuelen;
if(arg != NULL) {
if (arg != NULL) {
memcpy(seg->p->payload, ptr, seglen);
}
seg->dataptr = seg->p->payload;
@@ -193,7 +193,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
* link (as it has to be ACKed by the remote party) we can safely use PBUF_ROM
* instead of PBUF_REF here.
*/
if((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) {
if ((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n"));
goto memerr;
}
@@ -202,7 +202,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
seg->dataptr = ptr;
/* Second, allocate a pbuf for the headers. */
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM)) == NULL) {
if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM)) == NULL) {
/* If allocation fails, we have to deallocate the data pbuf as
well. */
pbuf_free(p);
@@ -218,18 +218,18 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Now that there are more segments queued, we check again if the
length of the queue exceeds the configured maximum. */
if(queuelen > TCP_SND_QUEUELEN) {
if (queuelen > TCP_SND_QUEUELEN) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %d (%d)\n", queuelen, TCP_SND_QUEUELEN));
goto memerr;
}
seg->len = seglen;
/* if((flags & TCP_SYN) || (flags & TCP_FIN)) {
/* if ((flags & TCP_SYN) || (flags & TCP_FIN)) {
++seg->len;
}*/
/* Build TCP header. */
if(pbuf_header(seg->p, TCP_HLEN)) {
if (pbuf_header(seg->p, TCP_HLEN)) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n"));
@@ -247,7 +247,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* don't fill in tcphdr->ackno and tcphdr->wnd until later */
/* Copy the options into the header, if they are present. */
if(optdata == NULL) {
if (optdata == NULL) {
TCPH_OFFSET_SET(seg->tcphdr, 5 << 4);
}
else {
@@ -271,7 +271,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Now that the data to be enqueued has been broken up into TCP
segments in the queue variable, we add them to the end of the
pcb->unsent queue. */
if(pcb->unsent == NULL) {
if (pcb->unsent == NULL) {
useg = NULL;
}
else {
@@ -280,7 +280,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* If there is room in the last pbuf on the unsent queue,
chain the first pbuf on the queue together with that. */
if(useg != NULL &&
if (useg != NULL &&
TCP_TCPLEN(useg) != 0 &&
!(TCPH_FLAGS(useg->tcphdr) & (TCP_SYN | TCP_FIN)) &&
!(flags & (TCP_SYN | TCP_FIN)) &&
@@ -296,13 +296,13 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
useg->next = queue->next;
DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining, new len %u\n", useg->len));
if(seg == queue) {
if (seg == queue) {
seg = NULL;
}
memp_free(MEMP_TCP_SEG, queue);
}
else {
if(useg == NULL) {
if (useg == NULL) {
pcb->unsent = queue;
}
@@ -310,14 +310,14 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
useg->next = queue;
}
}
if((flags & TCP_SYN) || (flags & TCP_FIN)) {
if ((flags & TCP_SYN) || (flags & TCP_FIN)) {
++len;
}
pcb->snd_lbb += len;
pcb->snd_buf -= len;
pcb->snd_queuelen = queuelen;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %d (after enqueued)\n", pcb->snd_queuelen));
if(pcb->snd_queuelen != 0) {
if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL);
@@ -325,7 +325,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Set the PSH flag in the last segment that we enqueued, but only
if the segment has data (indicated by seglen > 0). */
if(seg != NULL && seglen > 0 && seg->tcphdr != NULL) {
if (seg != NULL && seglen > 0 && seg->tcphdr != NULL) {
TCPH_FLAGS_SET(seg->tcphdr, TCPH_FLAGS(seg->tcphdr) | TCP_PSH);
}
@@ -335,10 +335,10 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
++lwip_stats.tcp.memerr;
#endif /* TCP_STATS */
if(queue != NULL) {
if (queue != NULL) {
tcp_segs_free(queue);
}
if(pcb->snd_queuelen != 0) {
if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL);
@@ -363,7 +363,7 @@ tcp_output(struct tcp_pcb *pcb)
code. If so, we do not output anything. Instead, we rely on the
input processing code to call us when input processing is done
with. */
if(tcp_input_pcb == pcb) {
if (tcp_input_pcb == pcb) {
return ERR_OK;
}
@@ -378,12 +378,12 @@ tcp_output(struct tcp_pcb *pcb)
sent (either because the ->unsent queue is empty or because the
window doesn't allow it) we'll have to construct an empty ACK
segment and send it. */
if(pcb->flags & TF_ACK_NOW &&
if (pcb->flags & TF_ACK_NOW &&
(seg == NULL ||
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) {
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
if(p == NULL) {
if (p == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n"));
return ERR_BUF;
}
@@ -411,12 +411,12 @@ tcp_output(struct tcp_pcb *pcb)
}
#if TCP_OUTPUT_DEBUG
if(seg == NULL) {
if (seg == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", pcb->unsent));
}
#endif /* TCP_OUTPUT_DEBUG */
#if TCP_CWND_DEBUG
if(seg == NULL) {
if (seg == NULL) {
DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, seg == NULL, ack %lu\n",
pcb->snd_wnd, pcb->cwnd, wnd,
pcb->lastack));
@@ -428,7 +428,7 @@ tcp_output(struct tcp_pcb *pcb)
}
#endif /* TCP_CWND_DEBUG */
while(seg != NULL &&
while (seg != NULL &&
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) {
#if TCP_CWND_DEBUG
DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu, i%d\n",
@@ -441,20 +441,20 @@ tcp_output(struct tcp_pcb *pcb)
pcb->unsent = seg->next;
if(pcb->state != SYN_SENT) {
if (pcb->state != SYN_SENT) {
TCPH_FLAGS_SET(seg->tcphdr, TCPH_FLAGS(seg->tcphdr) | TCP_ACK);
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
}
tcp_output_segment(seg, pcb);
pcb->snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);
if(TCP_SEQ_LT(pcb->snd_max, pcb->snd_nxt)) {
if (TCP_SEQ_LT(pcb->snd_max, pcb->snd_nxt)) {
pcb->snd_max = pcb->snd_nxt;
}
/* put segment on unacknowledged list if length > 0 */
if(TCP_TCPLEN(seg) > 0) {
if (TCP_TCPLEN(seg) > 0) {
seg->next = NULL;
if(pcb->unacked == NULL) {
if (pcb->unacked == NULL) {
pcb->unacked = seg;
@@ -481,7 +481,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
seg->tcphdr->ackno = htonl(pcb->rcv_nxt);
/* silly window avoidance */
if(pcb->rcv_wnd < pcb->mss) {
if (pcb->rcv_wnd < pcb->mss) {
seg->tcphdr->wnd = 0;
} else {
/* advertise our receive window size in this TCP segment */
@@ -490,9 +490,9 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
/* If we don't have a local IP address, we get one by
calling ip_route(). */
if(ip_addr_isany(&(pcb->local_ip))) {
if (ip_addr_isany(&(pcb->local_ip))) {
netif = ip_route(&(pcb->remote_ip));
if(netif == NULL) {
if (netif == NULL) {
return;
}
ip_addr_set(&(pcb->local_ip), &(netif->ip_addr));
@@ -500,7 +500,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
pcb->rtime = 0;
if(pcb->rttest == 0) {
if (pcb->rttest == 0) {
pcb->rttest = tcp_ticks;
pcb->rtseq = ntohl(seg->tcphdr->seqno);
@@ -538,7 +538,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
struct pbuf *p;
struct tcp_hdr *tcphdr;
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
if(p == NULL) {
if (p == NULL) {
DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n"));
return;
}
@@ -570,7 +570,7 @@ tcp_rexmit(struct tcp_pcb *pcb)
{
struct tcp_seg *seg;
if(pcb->unacked == NULL) {
if (pcb->unacked == NULL) {
return;
}

View File

@@ -102,7 +102,7 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
dest = ntohs(udphdr->dest);
pcb = pcb_cache;
if(pcb != NULL &&
if (pcb != NULL &&
pcb->remote_port == src &&
pcb->local_port == dest &&
(ip_addr_isany(&pcb->remote_ip) ||
@@ -113,7 +113,7 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
}
else {
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->remote_port == src &&
if (pcb->remote_port == src &&
pcb->local_port == dest &&
(ip_addr_isany(&pcb->remote_ip) ||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
@@ -124,9 +124,9 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
}
}
if(pcb == NULL) {
if (pcb == NULL) {
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
if(pcb->remote_port == 0 &&
if (pcb->remote_port == 0 &&
pcb->local_port == dest &&
(ip_addr_isany(&pcb->remote_ip) ||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
@@ -140,7 +140,7 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
PERF_STOP("udp_lookup");
if(pcb != NULL) {
if (pcb != NULL) {
return 1;
}
else {
@@ -214,7 +214,7 @@ udp_input(struct pbuf *p, struct netif *inp)
ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));
/* PCB remote port matches UDP source port? */
if((pcb->remote_port == src) &&
if ((pcb->remote_port == src) &&
/* PCB local port matches UDP destination port? */
(pcb->local_port == dest) &&
/* accepting from any remote (source) IP address? or... */
@@ -239,7 +239,7 @@ udp_input(struct pbuf *p, struct netif *inp)
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip),
ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));
/* unconnected? */
if(((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
/* destination port matches? */
(pcb->local_port == dest) &&
/* not bound to a specific (local) interface address? or... */
@@ -252,17 +252,17 @@ udp_input(struct pbuf *p, struct netif *inp)
}
/* Check checksum if this is a match or if it was directed at us. */
if(pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))
{
DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n"));
pbuf_header(p, UDP_HLEN);
#ifdef IPv6
if(iphdr->nexthdr == IP_PROTO_UDPLITE) {
if (iphdr->nexthdr == IP_PROTO_UDPLITE) {
#else
if(IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
#endif /* IPv4 */
/* Do the UDP Lite checksum */
if(inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest),
IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) {
DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n"));
@@ -275,8 +275,8 @@ udp_input(struct pbuf *p, struct netif *inp)
goto end;
}
} else {
if(udphdr->chksum != 0) {
if(inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
if (udphdr->chksum != 0) {
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest),
IP_PROTO_UDP, p->tot_len) != 0) {
DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n"));
@@ -292,7 +292,7 @@ udp_input(struct pbuf *p, struct netif *inp)
}
}
pbuf_header(p, -UDP_HLEN);
if(pcb != NULL) {
if (pcb != NULL) {
snmp_inc_udpindatagrams();
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
} else {
@@ -301,7 +301,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* No match was found, send ICMP destination port unreachable unless
destination address was broadcast/multicast. */
if(!ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) &&
if (!ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) &&
!ip_addr_ismulticast(&iphdr->dest)) {
/* adjust pbuf pointer */
@@ -409,9 +409,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
udphdr->chksum = inet_chksum_pseudo(q, src_ip, &(pcb->remote_ip),
IP_PROTO_UDP, pcb->chksum_len);
/* chksum zero must become 0xffff, as zero means 'no checksum' */
if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
/* output to IP */
err = ip_output_if(q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif);
err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif);
snmp_inc_udpoutdatagrams();
} else {
DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len));
@@ -424,9 +424,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
}
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum));
snmp_inc_udpoutdatagrams();
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)\n"));
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
/* output to IP */
err = ip_output_if(q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);
err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);
}
/* did we chain a header earlier? */
@@ -544,9 +544,9 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;
if(pcb->local_port == 0) {
if (pcb->local_port == 0) {
err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
if(err != ERR_OK)
if (err != ERR_OK)
return err;
}
@@ -556,10 +556,10 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
#if 0
pcb->flags |= UDP_FLAGS_CONNECTED;
/* Nail down local IP for netconn_addr()/getsockname() */
if(ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
struct netif *netif;
if((netif = ip_route(&(pcb->remote_ip))) == NULL) {
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS
++lwip_stats.udp.rterr;
@@ -570,7 +570,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
is used to route output packets to the remote address. However, we
might want to accept incoming packets on any interface! */
pcb->local_ip = netif->ip_addr;
} else if(ip_addr_isany(&pcb->remote_ip)) {
} else if (ip_addr_isany(&pcb->remote_ip)) {
pcb->local_ip.addr = 0;
}
#endif
@@ -582,7 +582,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
/* Insert UDP PCB into the list of active UDP PCBs. */
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
if(pcb == ipcb) {
if (pcb == ipcb) {
/* already on the list, just return */
return ERR_OK;
}
@@ -628,7 +628,7 @@ udp_remove(struct udp_pcb *pcb)
/* pcb not 1st in list */
} else for(pcb2 = udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) {
/* find pcb in udp_pcbs list */
if(pcb2->next != NULL && pcb2->next == pcb) {
if (pcb2->next != NULL && pcb2->next == pcb) {
/* remove pcb from list */
pcb2->next = pcb->next;
}
@@ -648,7 +648,7 @@ udp_new(void) {
struct udp_pcb *pcb;
pcb = memp_malloc(MEMP_UDP_PCB);
/* could allocate UDP PCB? */
if(pcb != NULL) {
if (pcb != NULL) {
/* initialize PCB to all zeroes */
memset(pcb, 0, sizeof(struct udp_pcb));
}