Fixed tabs into spaces. Fixed other stylos.

This commit is contained in:
likewise 2003-04-16 07:39:48 +00:00
parent 7662015de6
commit 9bc16878ea
6 changed files with 39 additions and 45 deletions

View File

@ -33,9 +33,6 @@
#include "lwip/ip_addr.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_broadcast = { 0xffffffffUL };
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/

View File

@ -529,10 +529,11 @@ pbuf_free(struct pbuf *p)
*/
SYS_ARCH_PROTECT(old_level);
/* 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) {
/* all pbufs in a chain are referenced at least once */
LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0);
/* decrease reference count (number of pointers to pbuf) */
p->ref--;
/* this pbuf is no longer referenced to? */
if (p->ref == 0) {
@ -543,10 +544,10 @@ pbuf_free(struct pbuf *p)
p->len = p->tot_len = PBUF_POOL_BUFSIZE;
p->payload = (void *)((u8_t *)p + sizeof(struct pbuf));
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) {
memp_freep(MEMP_PBUF, p);
/* pbuf with data */
/* p->flags == PBUF_FLAG_RAM */
} else {
mem_free(p);
}
@ -554,7 +555,7 @@ pbuf_free(struct pbuf *p)
/* proceed to next pbuf */
p = q;
/* 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 {
/* stop walking through chain */
p = NULL;

View File

@ -266,9 +266,9 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
cpcb != NULL; cpcb = cpcb->next) {
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;
ip_addr_isany(ipaddr) ||
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
return ERR_USE;
}
}
}
@ -467,16 +467,16 @@ tcp_slowtmr(void)
u32_t eff_wnd;
u8_t pcb_remove; /* flag if a PCB should be removed */
err_t err;
err = ERR_OK;
++tcp_ticks;
/* Steps through all of the active PCBs. */
prev = NULL;
pcb = tcp_active_pcbs;
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"));
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
@ -484,29 +484,27 @@ tcp_slowtmr(void)
pcb_remove = 0;
if(pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
}
else if(pcb->nrtx == TCP_MAXRTX) {
else if (pcb->nrtx == TCP_MAXRTX) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
} else {
++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",
pcb->rtime, pcb->rto));
pcb->rtime, pcb->rto));
/* Double retransmission time-out unless we are trying to
connect to somebody (i.e., we are in SYN_SENT). */
if(pcb->state != SYN_SENT) {
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
}
tcp_rexmit(pcb);
/* Double retransmission time-out unless we are trying to
* connect to somebody (i.e., we are in SYN_SENT). */
if (pcb->state != SYN_SENT) {
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
}
tcp_rexmit(pcb);
/* Reduce congestion window and ssthresh. */
eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);
pcb->ssthresh = eff_wnd >> 1;
@ -514,16 +512,14 @@ tcp_slowtmr(void)
pcb->ssthresh = pcb->mss * 2;
}
pcb->cwnd = pcb->mss;
DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n",
pcb->cwnd, pcb->ssthresh));
}
}
/* 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) >
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
}

View File

@ -337,12 +337,12 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
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) {
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);
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;
}
}
@ -360,6 +360,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
pbuf_chain(q, p);
/* { 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));
/* adding a header within p succeeded */
} else {
/* first pbuf q equals given pbuf */
q = p;
@ -371,7 +372,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
udphdr->dest = htons(pcb->remote_port);
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));
#ifdef UDP_STATS
++lwip_stats.udp.rterr;
@ -379,8 +380,8 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
return ERR_RTE;
}
/* using IP_ANY_ADDR? */
if(ip_addr_isany(&pcb->local_ip)) {
/* use network interface IP address as source address */
if (ip_addr_isany(&pcb->local_ip)) {
/* use outgoing network interface IP address as source address */
src_ip = &(netif->ip_addr);
} else {
/* 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));
/* 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));
/* set UDP message length in UDP header */
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));
udphdr->len = htons(q->tot_len);
/* 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);
/* 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));
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));
rebind = 0;
/* 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? */
if (pcb == ipcb) {
/* pcb may occur at most once in active list */

View File

@ -208,7 +208,6 @@ struct tcp_pcb {
/* receiver varables */
u32_t rcv_nxt; /* next seqno expected */
u16_t rcv_wnd; /* receiver window */
/* Timers */
u32_t tmr;

View File

@ -72,10 +72,10 @@ struct udp_pcb {
struct udp_pcb * udp_new (void);
void udp_remove (struct udp_pcb *pcb);
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,
u16_t port);
void udp_disconnect (struct udp_pcb *pcb);
u16_t port);
void udp_disconnect (struct udp_pcb *pcb);
void udp_recv (struct udp_pcb *pcb,
void (* recv)(void *arg, struct udp_pcb *upcb,
struct pbuf *p,