mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Fixed tabs into spaces. Fixed other stylos.
This commit is contained in:
parent
7662015de6
commit
9bc16878ea
@ -33,9 +33,6 @@
|
|||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
#include "lwip/inet.h"
|
#include "lwip/inet.h"
|
||||||
|
|
||||||
|
/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */
|
||||||
const struct ip_addr ip_addr_any = { 0x00000000UL };
|
const struct ip_addr ip_addr_any = { 0x00000000UL };
|
||||||
const struct ip_addr ip_addr_broadcast = { 0xffffffffUL };
|
const struct ip_addr ip_addr_broadcast = { 0xffffffffUL };
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
|
@ -529,10 +529,11 @@ pbuf_free(struct pbuf *p)
|
|||||||
*/
|
*/
|
||||||
SYS_ARCH_PROTECT(old_level);
|
SYS_ARCH_PROTECT(old_level);
|
||||||
/* de-allocate all consecutive pbufs from the head of the chain that
|
/* de-allocate all consecutive pbufs from the head of the chain that
|
||||||
* obtain a zero reference count */
|
* obtain a zero reference count after decrementing*/
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
/* all pbufs in a chain are referenced at least once */
|
/* all pbufs in a chain are referenced at least once */
|
||||||
LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0);
|
LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0);
|
||||||
|
/* decrease reference count (number of pointers to pbuf) */
|
||||||
p->ref--;
|
p->ref--;
|
||||||
/* this pbuf is no longer referenced to? */
|
/* this pbuf is no longer referenced to? */
|
||||||
if (p->ref == 0) {
|
if (p->ref == 0) {
|
||||||
@ -543,10 +544,10 @@ pbuf_free(struct pbuf *p)
|
|||||||
p->len = p->tot_len = PBUF_POOL_BUFSIZE;
|
p->len = p->tot_len = PBUF_POOL_BUFSIZE;
|
||||||
p->payload = (void *)((u8_t *)p + sizeof(struct pbuf));
|
p->payload = (void *)((u8_t *)p + sizeof(struct pbuf));
|
||||||
PBUF_POOL_FREE(p);
|
PBUF_POOL_FREE(p);
|
||||||
/* a RAM/ROM referencing pbuf */
|
/* a ROM or RAM referencing pbuf */
|
||||||
} else if (p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF) {
|
} else if (p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF) {
|
||||||
memp_freep(MEMP_PBUF, p);
|
memp_freep(MEMP_PBUF, p);
|
||||||
/* pbuf with data */
|
/* p->flags == PBUF_FLAG_RAM */
|
||||||
} else {
|
} else {
|
||||||
mem_free(p);
|
mem_free(p);
|
||||||
}
|
}
|
||||||
@ -554,7 +555,7 @@ pbuf_free(struct pbuf *p)
|
|||||||
/* proceed to next pbuf */
|
/* proceed to next pbuf */
|
||||||
p = q;
|
p = q;
|
||||||
/* p->ref > 0, this pbuf is still referenced to */
|
/* p->ref > 0, this pbuf is still referenced to */
|
||||||
/* (so the remaining pbufs in chain as well) */
|
/* (and so the remaining pbufs in chain as well) */
|
||||||
} else {
|
} else {
|
||||||
/* stop walking through chain */
|
/* stop walking through chain */
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
@ -266,9 +266,9 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
cpcb != NULL; cpcb = cpcb->next) {
|
cpcb != NULL; cpcb = cpcb->next) {
|
||||||
if(cpcb->local_port == port) {
|
if(cpcb->local_port == port) {
|
||||||
if(ip_addr_isany(&(cpcb->local_ip)) ||
|
if(ip_addr_isany(&(cpcb->local_ip)) ||
|
||||||
ip_addr_isany(ipaddr) ||
|
ip_addr_isany(ipaddr) ||
|
||||||
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
|
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
|
||||||
return ERR_USE;
|
return ERR_USE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,16 +467,16 @@ tcp_slowtmr(void)
|
|||||||
u32_t eff_wnd;
|
u32_t eff_wnd;
|
||||||
u8_t pcb_remove; /* flag if a PCB should be removed */
|
u8_t pcb_remove; /* flag if a PCB should be removed */
|
||||||
err_t err;
|
err_t err;
|
||||||
|
|
||||||
err = ERR_OK;
|
err = ERR_OK;
|
||||||
|
|
||||||
++tcp_ticks;
|
++tcp_ticks;
|
||||||
|
|
||||||
/* Steps through all of the active PCBs. */
|
/* Steps through all of the active PCBs. */
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
pcb = tcp_active_pcbs;
|
pcb = tcp_active_pcbs;
|
||||||
if (pcb == NULL) DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n"));
|
if (pcb == NULL) DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n"));
|
||||||
while(pcb != NULL) {
|
while (pcb != NULL) {
|
||||||
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n"));
|
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n"));
|
||||||
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
|
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
|
||||||
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
|
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
|
||||||
@ -484,29 +484,27 @@ tcp_slowtmr(void)
|
|||||||
|
|
||||||
pcb_remove = 0;
|
pcb_remove = 0;
|
||||||
|
|
||||||
if(pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
|
if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
|
||||||
++pcb_remove;
|
++pcb_remove;
|
||||||
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
|
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
|
||||||
}
|
}
|
||||||
else if(pcb->nrtx == TCP_MAXRTX) {
|
else if (pcb->nrtx == TCP_MAXRTX) {
|
||||||
++pcb_remove;
|
++pcb_remove;
|
||||||
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
|
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
|
||||||
} else {
|
} else {
|
||||||
++pcb->rtime;
|
++pcb->rtime;
|
||||||
if(pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
|
if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
|
||||||
|
|
||||||
/* Time for a retransmission. */
|
/* Time for a retransmission. */
|
||||||
DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n",
|
DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n",
|
||||||
pcb->rtime, pcb->rto));
|
pcb->rtime, pcb->rto));
|
||||||
|
|
||||||
/* Double retransmission time-out unless we are trying to
|
/* Double retransmission time-out unless we are trying to
|
||||||
connect to somebody (i.e., we are in SYN_SENT). */
|
* connect to somebody (i.e., we are in SYN_SENT). */
|
||||||
if(pcb->state != SYN_SENT) {
|
if (pcb->state != SYN_SENT) {
|
||||||
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
|
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
|
||||||
}
|
}
|
||||||
|
tcp_rexmit(pcb);
|
||||||
tcp_rexmit(pcb);
|
|
||||||
|
|
||||||
/* Reduce congestion window and ssthresh. */
|
/* Reduce congestion window and ssthresh. */
|
||||||
eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);
|
eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);
|
||||||
pcb->ssthresh = eff_wnd >> 1;
|
pcb->ssthresh = eff_wnd >> 1;
|
||||||
@ -514,16 +512,14 @@ tcp_slowtmr(void)
|
|||||||
pcb->ssthresh = pcb->mss * 2;
|
pcb->ssthresh = pcb->mss * 2;
|
||||||
}
|
}
|
||||||
pcb->cwnd = pcb->mss;
|
pcb->cwnd = pcb->mss;
|
||||||
|
|
||||||
DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n",
|
DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n",
|
||||||
pcb->cwnd, pcb->ssthresh));
|
pcb->cwnd, pcb->ssthresh));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if this PCB has stayed too long in FIN-WAIT-2 */
|
/* Check if this PCB has stayed too long in FIN-WAIT-2 */
|
||||||
if(pcb->state == 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) {
|
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
|
||||||
++pcb_remove;
|
++pcb_remove;
|
||||||
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
|
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
|
||||||
}
|
}
|
||||||
|
@ -337,12 +337,12 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
|
|
||||||
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n"));
|
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n"));
|
||||||
|
|
||||||
/* if the PCB is not yet bound, bind it here */
|
/* if the PCB is not yet bound to a port, bind it here */
|
||||||
if (pcb->local_port == 0) {
|
if (pcb->local_port == 0) {
|
||||||
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound\n"));
|
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n"));
|
||||||
err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced bind failed\n"));
|
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n"));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,6 +360,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
pbuf_chain(q, p);
|
pbuf_chain(q, p);
|
||||||
/* { first pbuf q points to header pbuf } */
|
/* { first pbuf q points to header pbuf } */
|
||||||
DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
|
DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
|
||||||
|
/* adding a header within p succeeded */
|
||||||
} else {
|
} else {
|
||||||
/* first pbuf q equals given pbuf */
|
/* first pbuf q equals given pbuf */
|
||||||
q = p;
|
q = p;
|
||||||
@ -371,7 +372,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
udphdr->dest = htons(pcb->remote_port);
|
udphdr->dest = htons(pcb->remote_port);
|
||||||
udphdr->chksum = 0x0000;
|
udphdr->chksum = 0x0000;
|
||||||
|
|
||||||
if((netif = ip_route(&(pcb->remote_ip))) == NULL) {
|
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
|
||||||
DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
||||||
#ifdef UDP_STATS
|
#ifdef UDP_STATS
|
||||||
++lwip_stats.udp.rterr;
|
++lwip_stats.udp.rterr;
|
||||||
@ -379,8 +380,8 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
return ERR_RTE;
|
return ERR_RTE;
|
||||||
}
|
}
|
||||||
/* using IP_ANY_ADDR? */
|
/* using IP_ANY_ADDR? */
|
||||||
if(ip_addr_isany(&pcb->local_ip)) {
|
if (ip_addr_isany(&pcb->local_ip)) {
|
||||||
/* use network interface IP address as source address */
|
/* use outgoing network interface IP address as source address */
|
||||||
src_ip = &(netif->ip_addr);
|
src_ip = &(netif->ip_addr);
|
||||||
} else {
|
} else {
|
||||||
/* use UDP PCB local IP address as source address */
|
/* use UDP PCB local IP address as source address */
|
||||||
@ -390,7 +391,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len));
|
DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len));
|
||||||
|
|
||||||
/* UDP Lite protocol? */
|
/* UDP Lite protocol? */
|
||||||
if(pcb->flags & UDP_FLAGS_UDPLITE) {
|
if (pcb->flags & UDP_FLAGS_UDPLITE) {
|
||||||
DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len));
|
DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len));
|
||||||
/* set UDP message length in UDP header */
|
/* set UDP message length in UDP header */
|
||||||
udphdr->len = htons(pcb->chksum_len);
|
udphdr->len = htons(pcb->chksum_len);
|
||||||
@ -406,10 +407,10 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len));
|
DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len));
|
||||||
udphdr->len = htons(q->tot_len);
|
udphdr->len = htons(q->tot_len);
|
||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
if((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {
|
if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {
|
||||||
udphdr->chksum = inet_chksum_pseudo(q, src_ip, &pcb->remote_ip, IP_PROTO_UDP, q->tot_len);
|
udphdr->chksum = inet_chksum_pseudo(q, src_ip, &pcb->remote_ip, IP_PROTO_UDP, q->tot_len);
|
||||||
/* chksum zero must become 0xffff, as zero means 'no checksum' */
|
/* chksum zero must become 0xffff, as zero means 'no checksum' */
|
||||||
if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
|
if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
|
||||||
}
|
}
|
||||||
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum));
|
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum));
|
||||||
snmp_inc_udpoutdatagrams();
|
snmp_inc_udpoutdatagrams();
|
||||||
@ -453,7 +454,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = %lx, port = %u)\n", ipaddr->addr, port));
|
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = %lx, port = %u)\n", ipaddr->addr, port));
|
||||||
rebind = 0;
|
rebind = 0;
|
||||||
/* Check for double bind and rebind of the same pcb */
|
/* Check for double bind and rebind of the same pcb */
|
||||||
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
|
for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
|
||||||
/* is this UDP PCB already on active list? */
|
/* is this UDP PCB already on active list? */
|
||||||
if (pcb == ipcb) {
|
if (pcb == ipcb) {
|
||||||
/* pcb may occur at most once in active list */
|
/* pcb may occur at most once in active list */
|
||||||
|
@ -208,7 +208,6 @@ struct tcp_pcb {
|
|||||||
/* receiver varables */
|
/* receiver varables */
|
||||||
u32_t rcv_nxt; /* next seqno expected */
|
u32_t rcv_nxt; /* next seqno expected */
|
||||||
u16_t rcv_wnd; /* receiver window */
|
u16_t rcv_wnd; /* receiver window */
|
||||||
|
|
||||||
|
|
||||||
/* Timers */
|
/* Timers */
|
||||||
u32_t tmr;
|
u32_t tmr;
|
||||||
|
@ -72,10 +72,10 @@ struct udp_pcb {
|
|||||||
struct udp_pcb * udp_new (void);
|
struct udp_pcb * udp_new (void);
|
||||||
void udp_remove (struct udp_pcb *pcb);
|
void udp_remove (struct udp_pcb *pcb);
|
||||||
err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
||||||
u16_t port);
|
u16_t port);
|
||||||
err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
||||||
u16_t port);
|
u16_t port);
|
||||||
void udp_disconnect (struct udp_pcb *pcb);
|
void udp_disconnect (struct udp_pcb *pcb);
|
||||||
void udp_recv (struct udp_pcb *pcb,
|
void udp_recv (struct udp_pcb *pcb,
|
||||||
void (* recv)(void *arg, struct udp_pcb *upcb,
|
void (* recv)(void *arg, struct udp_pcb *upcb,
|
||||||
struct pbuf *p,
|
struct pbuf *p,
|
||||||
|
Loading…
Reference in New Issue
Block a user