Revert "Test / RFC: Reformat a few files using clang-format"
This reverts commit 8b4a8159a8.
We do not want to do this shortly before a release. Reformatting (buggy reformatting) may introduce new bugs.
This commit is contained in:
@@ -44,13 +44,13 @@
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/raw.h"
|
||||
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/mld6.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
|
||||
@@ -59,14 +59,10 @@
|
||||
/* netconns are polled once per second (e.g. continue write on memory error) */
|
||||
#define NETCONN_TCP_POLL_INTERVAL 2
|
||||
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) \
|
||||
do { \
|
||||
if (val) { \
|
||||
netconn_set_flags(conn, NETCONN_FLAG_IN_NONBLOCKING_CONNECT); \
|
||||
} else { \
|
||||
netconn_clear_flags(conn, NETCONN_FLAG_IN_NONBLOCKING_CONNECT); \
|
||||
} \
|
||||
} while (0)
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) do { if (val) { \
|
||||
netconn_set_flags(conn, NETCONN_FLAG_IN_NONBLOCKING_CONNECT); \
|
||||
} else { \
|
||||
netconn_clear_flags(conn, NETCONN_FLAG_IN_NONBLOCKING_CONNECT); }} while(0)
|
||||
#define IN_NONBLOCKING_CONNECT(conn) netconn_is_flag_set(conn, NETCONN_FLAG_IN_NONBLOCKING_CONNECT)
|
||||
|
||||
#if LWIP_NETCONN_FULLDUPLEX
|
||||
@@ -78,28 +74,22 @@
|
||||
/* forward declarations */
|
||||
#if LWIP_TCP
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
#define WRITE_DELAYED , 1
|
||||
#define WRITE_DELAYED_PARAM , u8_t delayed
|
||||
#define WRITE_DELAYED , 1
|
||||
#define WRITE_DELAYED_PARAM , u8_t delayed
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define WRITE_DELAYED
|
||||
#define WRITE_DELAYED_PARAM
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
static err_t
|
||||
lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM);
|
||||
static err_t
|
||||
lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM);
|
||||
static err_t lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM);
|
||||
static err_t lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM);
|
||||
#endif
|
||||
|
||||
static void
|
||||
netconn_drain(struct netconn *conn);
|
||||
static void netconn_drain(struct netconn *conn);
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
#define TCPIP_APIMSG_ACK(m)
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define TCPIP_APIMSG_ACK(m) \
|
||||
do { \
|
||||
sys_sem_signal(LWIP_API_MSG_SEM(m)); \
|
||||
} while (0)
|
||||
#define TCPIP_APIMSG_ACK(m) do { sys_sem_signal(LWIP_API_MSG_SEM(m)); } while(0)
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#if LWIP_NETCONN_FULLDUPLEX
|
||||
@@ -156,6 +146,7 @@ lwip_netconn_is_err_msg(void *msg, err_t *err)
|
||||
}
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
|
||||
#if LWIP_RAW
|
||||
/**
|
||||
* Receive callback function for RAW netconns.
|
||||
@@ -165,7 +156,8 @@ lwip_netconn_is_err_msg(void *msg, err_t *err)
|
||||
* @see raw.h (struct raw_pcb.recv) for parameters and return value
|
||||
*/
|
||||
static u8_t
|
||||
recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
|
||||
recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr)
|
||||
{
|
||||
struct pbuf *q;
|
||||
struct netbuf *buf;
|
||||
@@ -223,7 +215,8 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
|
||||
* @see udp.h (struct udp_pcb.recv) for parameters
|
||||
*/
|
||||
static void
|
||||
recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
struct netbuf *buf;
|
||||
struct netconn *conn;
|
||||
@@ -246,7 +239,8 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
|
||||
#if LWIP_SO_RCVBUF
|
||||
SYS_ARCH_GET(conn->recv_avail, recv_avail);
|
||||
if (!NETCONN_MBOX_VALID(conn, &conn->recvmbox) || ((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize)) {
|
||||
if (!NETCONN_MBOX_VALID(conn, &conn->recvmbox) ||
|
||||
((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize)) {
|
||||
#else /* LWIP_SO_RCVBUF */
|
||||
if (!NETCONN_MBOX_VALID(conn, &conn->recvmbox)) {
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
@@ -368,14 +362,14 @@ poll_tcp(void *arg, struct tcp_pcb *pcb)
|
||||
LWIP_ASSERT("conn != NULL", (conn != NULL));
|
||||
|
||||
if (conn->state == NETCONN_WRITE) {
|
||||
lwip_netconn_do_writemore(conn WRITE_DELAYED);
|
||||
lwip_netconn_do_writemore(conn WRITE_DELAYED);
|
||||
} else if (conn->state == NETCONN_CLOSE) {
|
||||
#if !LWIP_SO_SNDTIMEO && !LWIP_SO_LINGER
|
||||
if (conn->current_msg && conn->current_msg->msg.sd.polls_left) {
|
||||
conn->current_msg->msg.sd.polls_left--;
|
||||
}
|
||||
#endif /* !LWIP_SO_SNDTIMEO && !LWIP_SO_LINGER */
|
||||
lwip_netconn_do_close_internal(conn WRITE_DELAYED);
|
||||
lwip_netconn_do_close_internal(conn WRITE_DELAYED);
|
||||
}
|
||||
/* @todo: implement connect timeout here? */
|
||||
|
||||
@@ -410,9 +404,9 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
|
||||
if (conn) {
|
||||
if (conn->state == NETCONN_WRITE) {
|
||||
lwip_netconn_do_writemore(conn WRITE_DELAYED);
|
||||
lwip_netconn_do_writemore(conn WRITE_DELAYED);
|
||||
} else if (conn->state == NETCONN_CLOSE) {
|
||||
lwip_netconn_do_close_internal(conn WRITE_DELAYED);
|
||||
lwip_netconn_do_close_internal(conn WRITE_DELAYED);
|
||||
}
|
||||
|
||||
/* If the queued byte- or pbuf-count drops below the configured low-water limit,
|
||||
@@ -479,7 +473,8 @@ err_tcp(void *arg, err_t err)
|
||||
sys_mbox_trypost(&conn->acceptmbox, mbox_msg);
|
||||
}
|
||||
|
||||
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) || (old_state == NETCONN_CONNECT)) {
|
||||
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
|
||||
(old_state == NETCONN_CONNECT)) {
|
||||
/* calling lwip_netconn_do_writemore/lwip_netconn_do_close_internal is not necessary
|
||||
since the pcb has already been deleted! */
|
||||
int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn);
|
||||
@@ -760,14 +755,14 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
|
||||
#if LWIP_TCP
|
||||
sys_mbox_set_invalid(&conn->acceptmbox);
|
||||
#endif
|
||||
conn->state = NETCONN_NONE;
|
||||
conn->state = NETCONN_NONE;
|
||||
#if LWIP_SOCKET
|
||||
/* initialize socket to -1 since 0 is a valid socket */
|
||||
conn->socket = -1;
|
||||
conn->socket = -1;
|
||||
#endif /* LWIP_SOCKET */
|
||||
conn->callback = callback;
|
||||
conn->callback = callback;
|
||||
#if LWIP_TCP
|
||||
conn->current_msg = NULL;
|
||||
conn->current_msg = NULL;
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
conn->send_timeout = 0;
|
||||
@@ -777,7 +772,7 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
|
||||
#endif /* LWIP_SO_RCVTIMEO */
|
||||
#if LWIP_SO_RCVBUF
|
||||
conn->recv_bufsize = RECV_BUFSIZE_DEFAULT;
|
||||
conn->recv_avail = 0;
|
||||
conn->recv_avail = 0;
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
#if LWIP_SO_LINGER
|
||||
conn->linger = -1;
|
||||
@@ -805,9 +800,11 @@ netconn_free(struct netconn *conn)
|
||||
netconn_drain(conn);
|
||||
#endif /* LWIP_NETCONN_FULLDUPLEX */
|
||||
|
||||
LWIP_ASSERT("recvmbox must be deallocated before calling this function", !sys_mbox_valid(&conn->recvmbox));
|
||||
LWIP_ASSERT("recvmbox must be deallocated before calling this function",
|
||||
!sys_mbox_valid(&conn->recvmbox));
|
||||
#if LWIP_TCP
|
||||
LWIP_ASSERT("acceptmbox must be deallocated before calling this function", !sys_mbox_valid(&conn->acceptmbox));
|
||||
LWIP_ASSERT("acceptmbox must be deallocated before calling this function",
|
||||
!sys_mbox_valid(&conn->acceptmbox));
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#if !LWIP_NETCONN_SEM_PER_THREAD
|
||||
@@ -920,7 +917,7 @@ netconn_mark_mbox_invalid(struct netconn *conn)
|
||||
* @param conn the TCP netconn to close
|
||||
*/
|
||||
static err_t
|
||||
lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
{
|
||||
err_t err;
|
||||
u8_t shut, shut_rx, shut_tx, shut_close;
|
||||
@@ -944,7 +941,10 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
(also if RD or WR side was shut down before already) */
|
||||
if (shut == NETCONN_SHUT_RDWR) {
|
||||
shut_close = 1;
|
||||
} else if (shut_rx && ((tpcb->state == FIN_WAIT_1) || (tpcb->state == FIN_WAIT_2) || (tpcb->state == CLOSING))) {
|
||||
} else if (shut_rx &&
|
||||
((tpcb->state == FIN_WAIT_1) ||
|
||||
(tpcb->state == FIN_WAIT_2) ||
|
||||
(tpcb->state == CLOSING))) {
|
||||
shut_close = 1;
|
||||
} else if (shut_tx && ((tpcb->flags & TF_RXCLOSED) != 0)) {
|
||||
shut_close = 1;
|
||||
@@ -988,7 +988,8 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
if (netconn_is_nonblocking(conn)) {
|
||||
/* data left on a nonblocking netconn -> cannot linger */
|
||||
err = ERR_WOULDBLOCK;
|
||||
} else if ((s32_t)(sys_now() - conn->current_msg->msg.sd.time_started) >= (conn->linger * 1000)) {
|
||||
} else if ((s32_t)(sys_now() - conn->current_msg->msg.sd.time_started) >=
|
||||
(conn->linger * 1000)) {
|
||||
/* data left but linger timeout has expired (this happens on further
|
||||
calls to this function through poll_tcp */
|
||||
tcp_abort(tpcb);
|
||||
@@ -1037,7 +1038,7 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
}
|
||||
#endif
|
||||
if ((s32_t)(sys_now() - conn->current_msg->msg.sd.time_started) >= close_timeout) {
|
||||
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
|
||||
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
|
||||
if (conn->current_msg->msg.sd.polls_left == 0) {
|
||||
#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
|
||||
close_finished = 1;
|
||||
@@ -1119,7 +1120,8 @@ lwip_netconn_do_delconn(void *m)
|
||||
#if LWIP_NETCONN_FULLDUPLEX
|
||||
/* In full duplex mode, blocking write/connect is aborted with ERR_CLSD */
|
||||
if (state != NETCONN_NONE) {
|
||||
if ((state == NETCONN_WRITE) || ((state == NETCONN_CONNECT) && !IN_NONBLOCKING_CONNECT(msg->conn))) {
|
||||
if ((state == NETCONN_WRITE) ||
|
||||
((state == NETCONN_CONNECT) && !IN_NONBLOCKING_CONNECT(msg->conn))) {
|
||||
/* close requested, abort running write/connect */
|
||||
sys_sem_t *op_completed_sem;
|
||||
LWIP_ASSERT("msg->conn->current_msg != NULL", msg->conn->current_msg != NULL);
|
||||
@@ -1130,8 +1132,10 @@ lwip_netconn_do_delconn(void *m)
|
||||
sys_sem_signal(op_completed_sem);
|
||||
}
|
||||
}
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
if (((state != NETCONN_NONE) && (state != NETCONN_LISTEN) && (state != NETCONN_CONNECT)) ||
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
if (((state != NETCONN_NONE) &&
|
||||
(state != NETCONN_LISTEN) &&
|
||||
(state != NETCONN_CONNECT)) ||
|
||||
((state == NETCONN_CONNECT) && !IN_NONBLOCKING_CONNECT(msg->conn))) {
|
||||
/* This means either a blocking write or blocking connect is running
|
||||
(nonblocking write returns and sets state to NONE) */
|
||||
@@ -1139,12 +1143,13 @@ lwip_netconn_do_delconn(void *m)
|
||||
} else
|
||||
#endif /* LWIP_NETCONN_FULLDUPLEX */
|
||||
{
|
||||
LWIP_ASSERT("blocking connect in progress", (state != NETCONN_CONNECT) || IN_NONBLOCKING_CONNECT(msg->conn));
|
||||
LWIP_ASSERT("blocking connect in progress",
|
||||
(state != NETCONN_CONNECT) || IN_NONBLOCKING_CONNECT(msg->conn));
|
||||
msg->err = ERR_OK;
|
||||
#if LWIP_NETCONN_FULLDUPLEX
|
||||
/* Mark mboxes invalid */
|
||||
netconn_mark_mbox_invalid(msg->conn);
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
netconn_drain(msg->conn);
|
||||
#endif /* LWIP_NETCONN_FULLDUPLEX */
|
||||
|
||||
@@ -1176,7 +1181,7 @@ lwip_netconn_do_delconn(void *m)
|
||||
LOCK_TCPIP_CORE();
|
||||
LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE);
|
||||
}
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
lwip_netconn_do_close_internal(msg->conn);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
/* API_EVENT is called inside lwip_netconn_do_close_internal, before releasing
|
||||
@@ -1321,7 +1326,8 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
was_blocking = !IN_NONBLOCKING_CONNECT(conn);
|
||||
SET_NONBLOCKING_CONNECT(conn, 0);
|
||||
LWIP_ASSERT("blocking connect state error",
|
||||
(was_blocking && op_completed_sem != NULL) || (!was_blocking && op_completed_sem == NULL));
|
||||
(was_blocking && op_completed_sem != NULL) ||
|
||||
(!was_blocking && op_completed_sem == NULL));
|
||||
conn->current_msg = NULL;
|
||||
conn->state = NETCONN_NONE;
|
||||
API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0);
|
||||
@@ -1370,8 +1376,8 @@ lwip_netconn_do_connect(void *m)
|
||||
err = ERR_ISCONN;
|
||||
} else {
|
||||
setup_tcp(msg->conn);
|
||||
err = tcp_connect(
|
||||
msg->conn->pcb.tcp, API_EXPR_REF(msg->msg.bc.ipaddr), msg->msg.bc.port, lwip_netconn_do_connected);
|
||||
err = tcp_connect(msg->conn->pcb.tcp, API_EXPR_REF(msg->msg.bc.ipaddr),
|
||||
msg->msg.bc.port, lwip_netconn_do_connected);
|
||||
if (err == ERR_OK) {
|
||||
u8_t non_blocking = netconn_is_nonblocking(msg->conn);
|
||||
msg->conn->state = NETCONN_CONNECT;
|
||||
@@ -1396,7 +1402,9 @@ lwip_netconn_do_connect(void *m)
|
||||
break;
|
||||
#endif /* LWIP_TCP */
|
||||
default:
|
||||
LWIP_ERROR("Invalid netconn type", 0, do { err = ERR_VAL; } while (0));
|
||||
LWIP_ERROR("Invalid netconn type", 0, do {
|
||||
err = ERR_VAL;
|
||||
} while (0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1459,11 +1467,12 @@ lwip_netconn_do_listen(void *m)
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/* "Socket API like" dual-stack support: If IP to listen to is IP6_ADDR_ANY,
|
||||
* and NETCONN_FLAG_IPV6_V6ONLY is NOT set, use IP_ANY_TYPE to listen
|
||||
*/
|
||||
if (ip_addr_cmp(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) && (netconn_get_ipv6only(msg->conn) == 0)) {
|
||||
* and NETCONN_FLAG_IPV6_V6ONLY is NOT set, use IP_ANY_TYPE to listen
|
||||
*/
|
||||
if (ip_addr_cmp(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) &&
|
||||
(netconn_get_ipv6only(msg->conn) == 0)) {
|
||||
/* change PCB type to IPADDR_TYPE_ANY */
|
||||
IP_SET_TYPE_VAL(msg->conn->pcb.tcp->local_ip, IPADDR_TYPE_ANY);
|
||||
IP_SET_TYPE_VAL(msg->conn->pcb.tcp->local_ip, IPADDR_TYPE_ANY);
|
||||
IP_SET_TYPE_VAL(msg->conn->pcb.tcp->remote_ip, IPADDR_TYPE_ANY);
|
||||
}
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
@@ -1541,17 +1550,14 @@ lwip_netconn_do_send(void *m)
|
||||
case NETCONN_UDP:
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
if (ip_addr_isany(&msg->msg.b->addr) || IP_IS_ANY_TYPE_VAL(msg->msg.b->addr)) {
|
||||
err = udp_send_chksum(
|
||||
msg->conn->pcb.udp, msg->msg.b->p, msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum);
|
||||
err = udp_send_chksum(msg->conn->pcb.udp, msg->msg.b->p,
|
||||
msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum);
|
||||
} else {
|
||||
err = udp_sendto_chksum(msg->conn->pcb.udp,
|
||||
msg->msg.b->p,
|
||||
&msg->msg.b->addr,
|
||||
msg->msg.b->port,
|
||||
msg->msg.b->flags & NETBUF_FLAG_CHKSUM,
|
||||
msg->msg.b->toport_chksum);
|
||||
err = udp_sendto_chksum(msg->conn->pcb.udp, msg->msg.b->p,
|
||||
&msg->msg.b->addr, msg->msg.b->port,
|
||||
msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum);
|
||||
}
|
||||
#else /* LWIP_CHECKSUM_ON_COPY */
|
||||
#else /* LWIP_CHECKSUM_ON_COPY */
|
||||
if (ip_addr_isany_val(msg->msg.b->addr) || IP_IS_ANY_TYPE_VAL(msg->msg.b->addr)) {
|
||||
err = udp_send(msg->conn->pcb.udp, msg->msg.b->p);
|
||||
} else {
|
||||
@@ -1631,7 +1637,7 @@ lwip_netconn_do_accepted(void *m)
|
||||
* ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished
|
||||
*/
|
||||
static err_t
|
||||
lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
{
|
||||
err_t err;
|
||||
const void *dataptr;
|
||||
@@ -1654,7 +1660,8 @@ lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);
|
||||
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
if ((conn->send_timeout != 0) && ((s32_t)(sys_now() - conn->current_msg->msg.w.time_started) >= conn->send_timeout)) {
|
||||
if ((conn->send_timeout != 0) &&
|
||||
((s32_t)(sys_now() - conn->current_msg->msg.w.time_started) >= conn->send_timeout)) {
|
||||
write_finished = 1;
|
||||
if (conn->current_msg->msg.w.offset == 0) {
|
||||
/* nothing has been written */
|
||||
@@ -1695,7 +1702,8 @@ lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
1) We couldn't finish the current vector because of 16-bit size limitations.
|
||||
tcp_write() and tcp_sndbuf() both are limited to 16-bit sizes
|
||||
2) We are sending the remainder of the current vector and have more */
|
||||
if ((len == 0xffff && diff > 0xffffUL) || (len == (u16_t)diff && conn->current_msg->msg.w.vector_cnt > 1)) {
|
||||
if ((len == 0xffff && diff > 0xffffUL) ||
|
||||
(len == (u16_t)diff && conn->current_msg->msg.w.vector_cnt > 1)) {
|
||||
write_more = 1;
|
||||
apiflags |= TCP_WRITE_FLAG_MORE;
|
||||
} else {
|
||||
@@ -1718,13 +1726,14 @@ lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
} while (write_more && err == ERR_OK);
|
||||
/* if OK or memory error, check available space */
|
||||
if ((err == ERR_OK) || (err == ERR_MEM)) {
|
||||
err_mem:
|
||||
err_mem:
|
||||
if (dontblock && (conn->current_msg->msg.w.offset < conn->current_msg->msg.w.len)) {
|
||||
/* non-blocking write did not write everything: mark the pcb non-writable
|
||||
and let poll_tcp check writable space to mark the pcb writable again */
|
||||
API_EVENT(conn, NETCONN_EVT_SENDMINUS, 0);
|
||||
conn->flags |= NETCONN_FLAG_CHECK_WRITESPACE;
|
||||
} else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) || (tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) {
|
||||
} else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) ||
|
||||
(tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) {
|
||||
/* The queued byte- or pbuf-count exceeds the configured low-water limit,
|
||||
let select mark this pcb as non-writable. */
|
||||
API_EVENT(conn, NETCONN_EVT_SENDMINUS, 0);
|
||||
@@ -1826,7 +1835,7 @@ lwip_netconn_do_write(void *m)
|
||||
LOCK_TCPIP_CORE();
|
||||
LWIP_ASSERT("state!", msg->conn->state != NETCONN_WRITE);
|
||||
}
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
lwip_netconn_do_writemore(msg->conn);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
/* for both cases: if lwip_netconn_do_writemore was called, don't ACK the APIMSG
|
||||
@@ -1835,7 +1844,7 @@ lwip_netconn_do_write(void *m)
|
||||
} else {
|
||||
err = ERR_CONN;
|
||||
}
|
||||
#else /* LWIP_TCP */
|
||||
#else /* LWIP_TCP */
|
||||
err = ERR_VAL;
|
||||
#endif /* LWIP_TCP */
|
||||
#if (LWIP_UDP || LWIP_RAW)
|
||||
@@ -1861,9 +1870,11 @@ lwip_netconn_do_getaddr(void *m)
|
||||
|
||||
if (msg->conn->pcb.ip != NULL) {
|
||||
if (msg->msg.ad.local) {
|
||||
ip_addr_copy(API_EXPR_DEREF(msg->msg.ad.ipaddr), msg->conn->pcb.ip->local_ip);
|
||||
ip_addr_copy(API_EXPR_DEREF(msg->msg.ad.ipaddr),
|
||||
msg->conn->pcb.ip->local_ip);
|
||||
} else {
|
||||
ip_addr_copy(API_EXPR_DEREF(msg->msg.ad.ipaddr), msg->conn->pcb.ip->remote_ip);
|
||||
ip_addr_copy(API_EXPR_DEREF(msg->msg.ad.ipaddr),
|
||||
msg->conn->pcb.ip->remote_ip);
|
||||
}
|
||||
|
||||
msg->err = ERR_OK;
|
||||
@@ -1898,8 +1909,7 @@ lwip_netconn_do_getaddr(void *m)
|
||||
/* pcb is not connected and remote name is requested */
|
||||
msg->err = ERR_CONN;
|
||||
} else {
|
||||
API_EXPR_DEREF(msg->msg.ad.port) =
|
||||
(msg->msg.ad.local ? msg->conn->pcb.tcp->local_port : msg->conn->pcb.tcp->remote_port);
|
||||
API_EXPR_DEREF(msg->msg.ad.port) = (msg->msg.ad.local ? msg->conn->pcb.tcp->local_port : msg->conn->pcb.tcp->remote_port);
|
||||
}
|
||||
break;
|
||||
#endif /* LWIP_TCP */
|
||||
@@ -1929,7 +1939,8 @@ lwip_netconn_do_close(void *m)
|
||||
enum netconn_state state = msg->conn->state;
|
||||
/* First check if this is a TCP netconn and if it is in a correct state
|
||||
(LISTEN doesn't support half shutdown) */
|
||||
if ((msg->conn->pcb.tcp != NULL) && (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_TCP) &&
|
||||
if ((msg->conn->pcb.tcp != NULL) &&
|
||||
(NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_TCP) &&
|
||||
((msg->msg.sd.shut == NETCONN_SHUT_RDWR) || (state != NETCONN_LISTEN))) {
|
||||
/* Check if we are in a connected state */
|
||||
if (state == NETCONN_CONNECT) {
|
||||
@@ -1955,7 +1966,7 @@ lwip_netconn_do_close(void *m)
|
||||
}
|
||||
}
|
||||
if (state == NETCONN_NONE) {
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
msg->err = ERR_INPROGRESS;
|
||||
} else {
|
||||
#endif /* LWIP_NETCONN_FULLDUPLEX */
|
||||
@@ -1963,7 +1974,7 @@ lwip_netconn_do_close(void *m)
|
||||
#if LWIP_NETCONN_FULLDUPLEX
|
||||
/* Mark mboxes invalid */
|
||||
netconn_mark_mbox_invalid(msg->conn);
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
#else /* LWIP_NETCONN_FULLDUPLEX */
|
||||
netconn_drain(msg->conn);
|
||||
#endif /* LWIP_NETCONN_FULLDUPLEX */
|
||||
}
|
||||
@@ -1978,7 +1989,7 @@ lwip_netconn_do_close(void *m)
|
||||
LOCK_TCPIP_CORE();
|
||||
LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE);
|
||||
}
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
lwip_netconn_do_close_internal(msg->conn);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
/* for tcp netconns, lwip_netconn_do_close_internal ACKs the message */
|
||||
@@ -2064,18 +2075,22 @@ lwip_netconn_do_join_leave_group_netif(void *m)
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
if (NETCONNTYPE_ISIPV6(msg->conn->type)) {
|
||||
if (msg->msg.jl.join_or_leave == NETCONN_JOIN) {
|
||||
msg->err = mld6_joingroup_netif(netif, ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
msg->err = mld6_joingroup_netif(netif,
|
||||
ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
} else {
|
||||
msg->err = mld6_leavegroup_netif(netif, ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
msg->err = mld6_leavegroup_netif(netif,
|
||||
ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
}
|
||||
} else
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
{
|
||||
#if LWIP_IGMP
|
||||
if (msg->msg.jl.join_or_leave == NETCONN_JOIN) {
|
||||
msg->err = igmp_joingroup_netif(netif, ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
msg->err = igmp_joingroup_netif(netif,
|
||||
ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
} else {
|
||||
msg->err = igmp_leavegroup_netif(netif, ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
msg->err = igmp_leavegroup_netif(netif,
|
||||
ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
}
|
||||
@@ -2135,8 +2150,8 @@ lwip_netconn_do_gethostbyname(void *arg)
|
||||
LWIP_DNS_ADDRTYPE_DEFAULT;
|
||||
#endif
|
||||
|
||||
API_EXPR_DEREF(msg->err) =
|
||||
dns_gethostbyname_addrtype(msg->name, API_EXPR_REF(msg->addr), lwip_netconn_do_dns_found, msg, addrtype);
|
||||
API_EXPR_DEREF(msg->err) = dns_gethostbyname_addrtype(msg->name,
|
||||
API_EXPR_REF(msg->addr), lwip_netconn_do_dns_found, msg, addrtype);
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/* For core locking, only block if we need to wait for answer/timeout */
|
||||
if (API_EXPR_DEREF(msg->err) == ERR_INPROGRESS) {
|
||||
@@ -2145,7 +2160,7 @@ lwip_netconn_do_gethostbyname(void *arg)
|
||||
LOCK_TCPIP_CORE();
|
||||
LWIP_ASSERT("do_gethostbyname still in progress!!", API_EXPR_DEREF(msg->err) != ERR_INPROGRESS);
|
||||
}
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
if (API_EXPR_DEREF(msg->err) != ERR_INPROGRESS) {
|
||||
/* on error or immediate success, wake up the application
|
||||
* task waiting in netconn_gethostbyname */
|
||||
|
||||
Reference in New Issue
Block a user