diff --git a/src/core/tcp.c b/src/core/tcp.c index b3c4c29e..b8490a51 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -217,7 +217,7 @@ tcp_backlog_delayed(struct tcp_pcb* pcb) if (pcb->listener != NULL) { pcb->listener->accepts_pending++; LWIP_ASSERT("accepts_pending != 0", pcb->listener->accepts_pending != 0); - pcb->flags |= TF_BACKLOGPEND; + tcp_set_flags(pcb, TF_BACKLOGPEND); } } } @@ -369,7 +369,7 @@ tcp_close_shutdown_fin(struct tcp_pcb *pcb) tcp_output(pcb); } else if (err == ERR_MEM) { /* Mark this pcb for closing. Closing is retried from tcp_tmr. */ - pcb->flags |= TF_CLOSEPEND; + tcp_set_flags(pcb, TF_CLOSEPEND); } return err; } @@ -397,7 +397,7 @@ tcp_close(struct tcp_pcb *pcb) if (pcb->state != LISTEN) { /* Set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; + tcp_set_flags(pcb, TF_RXCLOSED); } /* ... and close */ return tcp_close_shutdown(pcb, 1); @@ -424,7 +424,7 @@ tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) } if (shut_rx) { /* shut down the receive side: set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; + tcp_set_flags(pcb, TF_RXCLOSED); if (shut_tx) { /* shutting down the tx AND rx side is the same as closing for the raw API */ return tcp_close_shutdown(pcb, 1); diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 8493a31f..ff29b32f 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -621,7 +621,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) } #if TCP_LISTEN_BACKLOG pcb->accepts_pending++; - npcb->flags |= TF_BACKLOGPEND; + tcp_set_flags(npcb, TF_BACKLOGPEND); #endif /* TCP_LISTEN_BACKLOG */ /* Set up the new PCB. */ ip_addr_copy(npcb->local_ip, *ip_current_dest_addr()); @@ -1911,7 +1911,7 @@ tcp_parseopt(struct tcp_pcb *pcb) pcb->snd_scale = 14U; } pcb->rcv_scale = TCP_RCV_SCALE; - pcb->flags |= TF_WND_SCALE; + tcp_set_flags(pcb, TF_WND_SCALE); /* window scaling is enabled, we can use the full receive window */ LWIP_ASSERT("window not at default value", pcb->rcv_wnd == TCPWND_MIN16(TCP_WND)); LWIP_ASSERT("window not at default value", pcb->rcv_ann_wnd == TCPWND_MIN16(TCP_WND)); @@ -1936,7 +1936,7 @@ tcp_parseopt(struct tcp_pcb *pcb) pcb->ts_recent = lwip_ntohl(tsval); /* Enable sending timestamps in every segment now that we know the remote host supports it. */ - pcb->flags |= TF_TIMESTAMP; + tcp_set_flags(pcb, TF_TIMESTAMP); } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { pcb->ts_recent = lwip_ntohl(tsval); } @@ -1955,7 +1955,7 @@ tcp_parseopt(struct tcp_pcb *pcb) /* TCP SACK_PERM option with valid length */ if (flags & TCP_SYN) { /* We only set it if we receive it in a SYN (or SYN+ACK) packet */ - pcb->flags |= TF_SACK; + tcp_set_flags(pcb, TF_SACK); } break; #endif /* LWIP_TCP_SACK_OUT */ diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 2ccaea57..63b0ee34 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -160,7 +160,7 @@ tcp_send_fin(struct tcp_pcb *pcb) if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN); - pcb->flags |= TF_FIN; + tcp_set_flags(pcb, TF_FIN); return ERR_OK; } } @@ -334,7 +334,7 @@ tcp_write_checks(struct tcp_pcb *pcb, u16_t len) if (len > pcb->snd_buf) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_write: too much data (len=%"U16_F" > snd_buf=%"TCPWNDSIZE_F")\n", len, pcb->snd_buf)); - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); return ERR_MEM; } @@ -347,7 +347,7 @@ tcp_write_checks(struct tcp_pcb *pcb, u16_t len) LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n", pcb->snd_queuelen, (u16_t)TCP_SND_QUEUELEN)); TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); return ERR_MEM; } if (pcb->snd_queuelen != 0) { @@ -776,7 +776,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) return ERR_OK; memerr: - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); TCP_STATS_INC(tcp.memerr); if (concat_p != NULL) { @@ -820,7 +820,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_enqueue_flags: too long queue %"U16_F" (max %"U16_F")\n", pcb->snd_queuelen, (u16_t)TCP_SND_QUEUELEN)); TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); return ERR_MEM; } @@ -852,7 +852,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) /* Allocate pbuf with room for TCP header + options */ if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); TCP_STATS_INC(tcp.memerr); return ERR_MEM; } @@ -861,7 +861,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) /* Allocate memory for tcp_seg, and fill in fields. */ if ((seg = tcp_create_segment(pcb, p, flags, pcb->snd_lbb, optflags)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); TCP_STATS_INC(tcp.memerr); return ERR_MEM; } @@ -893,7 +893,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) /* optlen does not influence snd_buf */ } if (flags & TCP_FIN) { - pcb->flags |= TF_FIN; + tcp_set_flags(pcb, TF_FIN); } /* update number of segments on the queues */ @@ -1030,7 +1030,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) p = tcp_output_alloc_header(pcb, optlen, 0, lwip_htonl(pcb->snd_nxt)); if (p == NULL) { /* let tcp_fasttmr retry sending this ACK */ - pcb->flags |= (TF_ACK_DELAY | TF_ACK_NOW); + tcp_set_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); return ERR_BUF; } @@ -1083,7 +1083,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) if (err != ERR_OK) { /* let tcp_fasttmr retry sending this ACK */ - pcb->flags |= (TF_ACK_DELAY | TF_ACK_NOW); + tcp_set_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); } else { /* remove ACK flags from the PCB, as we sent an empty ACK now */ tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); @@ -1230,7 +1230,7 @@ tcp_output(struct tcp_pcb *pcb) err = tcp_output_segment(seg, pcb, netif); if (err != ERR_OK) { /* segment could not be sent, for whatever reason */ - pcb->flags |= TF_NAGLEMEMERR; + tcp_set_flags(pcb, TF_NAGLEMEMERR); return err; } pcb->unsent = seg->next; @@ -1574,7 +1574,7 @@ tcp_rexmit_rto_prepare(struct tcp_pcb *pcb) pcb->unacked = NULL; /* Mark RTO in-progress */ - pcb->flags |= TF_RTO; + tcp_set_flags(pcb, TF_RTO); /* Record the next byte following retransmit */ pcb->rto_end = lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); /* Don't take any RTT measurements after retransmitting. */ @@ -1705,7 +1705,7 @@ tcp_rexmit_fast(struct tcp_pcb *pcb) } pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; - pcb->flags |= TF_INFR; + tcp_set_flags(pcb, TF_INFR); /* Reset the retransmission timer to prevent immediate rto retransmissions */ pcb->rtime = 0; diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h index 413f7d4f..a4319326 100644 --- a/src/include/lwip/priv/tcp_priv.h +++ b/src/include/lwip/priv/tcp_priv.h @@ -449,7 +449,7 @@ struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); tcp_ack_now(pcb); \ } \ else { \ - (pcb)->flags |= TF_ACK_DELAY; \ + tcp_set_flags(pcb, TF_ACK_DELAY); \ } \ } while (0)