fixed bug #35931: Name space pollution in api_msg.c and netifapi.c

This commit is contained in:
goldsimon 2012-03-25 14:41:27 +02:00
parent d95bcab053
commit f8af1a7443
5 changed files with 98 additions and 94 deletions

View File

@ -76,6 +76,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2012-03-25: Simon Goldschmidt
* api_msg.h, api_lib.c, api_msg.c, netifapi.c: fixed bug #35931: Name space
pollution in api_msg.c and netifapi.c
2012-03-22: Simon Goldschmidt 2012-03-22: Simon Goldschmidt
* ip4.c: fixed bug #35927: missing refragmentaion in ip_forward * ip4.c: fixed bug #35927: missing refragmentaion in ip_forward

View File

@ -75,7 +75,7 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal
err_t err; err_t err;
msg.msg.msg.n.proto = proto; msg.msg.msg.n.proto = proto;
msg.msg.conn = conn; msg.msg.conn = conn;
TCPIP_APIMSG((&msg), do_newconn, err); TCPIP_APIMSG((&msg), lwip_netconn_do_newconn, err);
if (err != ERR_OK) { if (err != ERR_OK) {
LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL); LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL);
LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed)); LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed));
@ -110,13 +110,13 @@ netconn_delete(struct netconn *conn)
return ERR_OK; return ERR_OK;
} }
msg.function = do_delconn; msg.function = lwip_netconn_do_delconn;
msg.msg.conn = conn; msg.msg.conn = conn;
tcpip_apimsg(&msg); tcpip_apimsg(&msg);
netconn_free(conn); netconn_free(conn);
/* don't care for return value of do_delconn since it only calls void functions */ /* don't care for return value of lwip_netconn_do_delconn since it only calls void functions */
return ERR_OK; return ERR_OK;
} }
@ -146,7 +146,7 @@ netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local)
msg.msg.msg.ad.ipaddr = ip_2_ipX(addr); msg.msg.msg.ad.ipaddr = ip_2_ipX(addr);
msg.msg.msg.ad.port = port; msg.msg.msg.ad.port = port;
msg.msg.msg.ad.local = local; msg.msg.msg.ad.local = local;
TCPIP_APIMSG(&msg, do_getaddr, err); TCPIP_APIMSG(&msg, lwip_netconn_do_getaddr, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -173,7 +173,7 @@ netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port)
msg.msg.conn = conn; msg.msg.conn = conn;
msg.msg.msg.bc.ipaddr = addr; msg.msg.msg.bc.ipaddr = addr;
msg.msg.msg.bc.port = port; msg.msg.msg.bc.port = port;
TCPIP_APIMSG(&msg, do_bind, err); TCPIP_APIMSG(&msg, lwip_netconn_do_bind, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -205,7 +205,7 @@ netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port)
{ {
/* The TCP version waits for the connect to succeed, /* The TCP version waits for the connect to succeed,
so always needs to use message passing. */ so always needs to use message passing. */
msg.function = do_connect; msg.function = lwip_netconn_do_connect;
err = tcpip_apimsg(&msg); err = tcpip_apimsg(&msg);
} }
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
@ -215,7 +215,7 @@ netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port)
#if (LWIP_UDP || LWIP_RAW) #if (LWIP_UDP || LWIP_RAW)
{ {
/* UDP and RAW only set flags, so we can use core-locking. */ /* UDP and RAW only set flags, so we can use core-locking. */
TCPIP_APIMSG(&msg, do_connect, err); TCPIP_APIMSG(&msg, lwip_netconn_do_connect, err);
} }
#endif /* (LWIP_UDP || LWIP_RAW) */ #endif /* (LWIP_UDP || LWIP_RAW) */
@ -238,7 +238,7 @@ netconn_disconnect(struct netconn *conn)
LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;); LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;);
msg.msg.conn = conn; msg.msg.conn = conn;
TCPIP_APIMSG(&msg, do_disconnect, err); TCPIP_APIMSG(&msg, lwip_netconn_do_disconnect, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -268,7 +268,7 @@ netconn_listen_with_backlog(struct netconn *conn, u8_t backlog)
#if TCP_LISTEN_BACKLOG #if TCP_LISTEN_BACKLOG
msg.msg.msg.lb.backlog = backlog; msg.msg.msg.lb.backlog = backlog;
#endif /* TCP_LISTEN_BACKLOG */ #endif /* TCP_LISTEN_BACKLOG */
TCPIP_APIMSG(&msg, do_listen, err); TCPIP_APIMSG(&msg, lwip_netconn_do_listen, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -328,8 +328,8 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
#if TCP_LISTEN_BACKLOG #if TCP_LISTEN_BACKLOG
/* Let the stack know that we have accepted the connection. */ /* Let the stack know that we have accepted the connection. */
msg.msg.conn = conn; msg.msg.conn = conn;
/* don't care for the return value of do_recv */ /* don't care for the return value of lwip_netconn_do_recv */
TCPIP_APIMSG_NOERR(&msg, do_recv); TCPIP_APIMSG_NOERR(&msg, lwip_netconn_do_recv);
#endif /* TCP_LISTEN_BACKLOG */ #endif /* TCP_LISTEN_BACKLOG */
*new_conn = newconn; *new_conn = newconn;
@ -399,8 +399,8 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
} else { } else {
msg.msg.msg.r.len = 1; msg.msg.msg.r.len = 1;
} }
/* don't care for the return value of do_recv */ /* don't care for the return value of lwip_netconn_do_recv */
TCPIP_APIMSG_NOERR(&msg, do_recv); TCPIP_APIMSG_NOERR(&msg, lwip_netconn_do_recv);
} }
/* If we are closed, we indicate that we no longer wish to use the socket */ /* If we are closed, we indicate that we no longer wish to use the socket */
@ -537,8 +537,8 @@ netconn_recved(struct netconn *conn, u32_t length)
(to prevent multiple thread-switches). */ (to prevent multiple thread-switches). */
msg.msg.conn = conn; msg.msg.conn = conn;
msg.msg.msg.r.len = length; msg.msg.msg.r.len = length;
/* don't care for the return value of do_recv */ /* don't care for the return value of lwip_netconn_do_recv */
TCPIP_APIMSG_NOERR(&msg, do_recv); TCPIP_APIMSG_NOERR(&msg, lwip_netconn_do_recv);
} }
#else /* LWIP_TCP */ #else /* LWIP_TCP */
LWIP_UNUSED_ARG(conn); LWIP_UNUSED_ARG(conn);
@ -585,7 +585,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len)); LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len));
msg.msg.conn = conn; msg.msg.conn = conn;
msg.msg.msg.b = buf; msg.msg.msg.b = buf;
TCPIP_APIMSG(&msg, do_send, err); TCPIP_APIMSG(&msg, lwip_netconn_do_send, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -642,7 +642,7 @@ netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
/* For locking the core: this _can_ be delayed on low memory/low send buffer, /* For locking the core: this _can_ be delayed on low memory/low send buffer,
but if it is, this is done inside api_msg.c:do_write(), so we can use the but if it is, this is done inside api_msg.c:do_write(), so we can use the
non-blocking version here. */ non-blocking version here. */
TCPIP_APIMSG(&msg, do_write, err); TCPIP_APIMSG(&msg, lwip_netconn_do_write, err);
if ((err == ERR_OK) && (bytes_written != NULL)) { if ((err == ERR_OK) && (bytes_written != NULL)) {
if (dontblock if (dontblock
#if LWIP_SO_SNDTIMEO #if LWIP_SO_SNDTIMEO
@ -676,11 +676,11 @@ netconn_close_shutdown(struct netconn *conn, u8_t how)
LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;); LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;);
msg.function = do_close; msg.function = lwip_netconn_do_close;
msg.msg.conn = conn; msg.msg.conn = conn;
/* shutting down both ends is the same as closing */ /* shutting down both ends is the same as closing */
msg.msg.msg.sd.shut = how; msg.msg.msg.sd.shut = how;
/* because of the LWIP_TCPIP_CORE_LOCKING implementation of do_close, /* because of the LWIP_TCPIP_CORE_LOCKING implementation of lwip_netconn_do_close,
don't use TCPIP_APIMSG here */ don't use TCPIP_APIMSG here */
err = tcpip_apimsg(&msg); err = tcpip_apimsg(&msg);
@ -739,7 +739,7 @@ netconn_join_leave_group(struct netconn *conn,
msg.msg.msg.jl.multiaddr = ip_2_ipX(multiaddr); msg.msg.msg.jl.multiaddr = ip_2_ipX(multiaddr);
msg.msg.msg.jl.netif_addr = ip_2_ipX(netif_addr); msg.msg.msg.jl.netif_addr = ip_2_ipX(netif_addr);
msg.msg.msg.jl.join_or_leave = join_or_leave; msg.msg.msg.jl.join_or_leave = join_or_leave;
TCPIP_APIMSG(&msg, do_join_leave_group, err); TCPIP_APIMSG(&msg, lwip_netconn_do_join_leave_group, err);
NETCONN_SET_SAFE_ERR(conn, err); NETCONN_SET_SAFE_ERR(conn, err);
return err; return err;
@ -777,7 +777,7 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
msg.err = &err; msg.err = &err;
msg.sem = &sem; msg.sem = &sem;
tcpip_callback(do_gethostbyname, &msg); tcpip_callback(lwip_netconn_do_gethostbyname, &msg);
sys_sem_wait(&sem); sys_sem_wait(&sem);
sys_sem_free(&sem); sys_sem_free(&sem);

View File

@ -63,8 +63,8 @@
/* forward declarations */ /* forward declarations */
#if LWIP_TCP #if LWIP_TCP
static err_t do_writemore(struct netconn *conn); static err_t lwip_netconn_do_writemore(struct netconn *conn);
static void do_close_internal(struct netconn *conn); static void lwip_netconn_do_close_internal(struct netconn *conn);
#endif #endif
#if LWIP_RAW #if LWIP_RAW
@ -282,9 +282,9 @@ poll_tcp(void *arg, struct tcp_pcb *pcb)
LWIP_ASSERT("conn != NULL", (conn != NULL)); LWIP_ASSERT("conn != NULL", (conn != NULL));
if (conn->state == NETCONN_WRITE) { if (conn->state == NETCONN_WRITE) {
do_writemore(conn); lwip_netconn_do_writemore(conn);
} else if (conn->state == NETCONN_CLOSE) { } else if (conn->state == NETCONN_CLOSE) {
do_close_internal(conn); lwip_netconn_do_close_internal(conn);
} }
/* @todo: implement connect timeout here? */ /* @todo: implement connect timeout here? */
@ -318,9 +318,9 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
LWIP_ASSERT("conn != NULL", (conn != NULL)); LWIP_ASSERT("conn != NULL", (conn != NULL));
if (conn->state == NETCONN_WRITE) { if (conn->state == NETCONN_WRITE) {
do_writemore(conn); lwip_netconn_do_writemore(conn);
} else if (conn->state == NETCONN_CLOSE) { } else if (conn->state == NETCONN_CLOSE) {
do_close_internal(conn); lwip_netconn_do_close_internal(conn);
} }
if (conn) { if (conn) {
@ -385,7 +385,7 @@ err_tcp(void *arg, err_t err)
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) || if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
(old_state == NETCONN_CONNECT)) { (old_state == NETCONN_CONNECT)) {
/* calling do_writemore/do_close_internal is not necessary /* calling lwip_netconn_do_writemore/lwip_netconn_do_close_internal is not necessary
since the pcb has already been deleted! */ since the pcb has already been deleted! */
int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn); int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn);
SET_NONBLOCKING_CONNECT(conn, 0); SET_NONBLOCKING_CONNECT(conn, 0);
@ -473,7 +473,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
/** /**
* Create a new pcb of a specific type. * Create a new pcb of a specific type.
* Called from do_newconn(). * Called from lwip_netconn_do_newconn().
* *
* @param msg the api_msg_msg describing the connection type * @param msg the api_msg_msg describing the connection type
* @return msg->conn->err, but the return value is currently ignored * @return msg->conn->err, but the return value is currently ignored
@ -541,7 +541,7 @@ pcb_new(struct api_msg_msg *msg)
* @param msg the api_msg_msg describing the connection type * @param msg the api_msg_msg describing the connection type
*/ */
void void
do_newconn(struct api_msg_msg *msg) lwip_netconn_do_newconn(struct api_msg_msg *msg)
{ {
msg->err = ERR_OK; msg->err = ERR_OK;
if(msg->conn->pcb.tcp == NULL) { if(msg->conn->pcb.tcp == NULL) {
@ -740,7 +740,7 @@ netconn_drain(struct netconn *conn)
* @param conn the TCP netconn to close * @param conn the TCP netconn to close
*/ */
static void static void
do_close_internal(struct netconn *conn) lwip_netconn_do_close_internal(struct netconn *conn)
{ {
err_t err; err_t err;
u8_t shut, shut_rx, shut_tx, close; u8_t shut, shut_rx, shut_tx, close;
@ -825,7 +825,7 @@ do_close_internal(struct netconn *conn)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_delconn(struct api_msg_msg *msg) lwip_netconn_do_delconn(struct api_msg_msg *msg)
{ {
/* @todo TCP: abort running write/connect? */ /* @todo TCP: abort running write/connect? */
if ((msg->conn->state != NETCONN_NONE) && if ((msg->conn->state != NETCONN_NONE) &&
@ -862,8 +862,8 @@ do_delconn(struct api_msg_msg *msg)
msg->conn->state = NETCONN_CLOSE; msg->conn->state = NETCONN_CLOSE;
msg->msg.sd.shut = NETCONN_SHUT_RDWR; msg->msg.sd.shut = NETCONN_SHUT_RDWR;
msg->conn->current_msg = msg; msg->conn->current_msg = msg;
do_close_internal(msg->conn); lwip_netconn_do_close_internal(msg->conn);
/* API_EVENT is called inside do_close_internal, before releasing /* API_EVENT is called inside lwip_netconn_do_close_internal, before releasing
the application thread, so we can return at this point! */ the application thread, so we can return at this point! */
return; return;
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
@ -892,7 +892,7 @@ do_delconn(struct api_msg_msg *msg)
* the IP address and port to bind to * the IP address and port to bind to
*/ */
void void
do_bind(struct api_msg_msg *msg) lwip_netconn_do_bind(struct api_msg_msg *msg)
{ {
if (ERR_IS_FATAL(msg->conn->last_err)) { if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err; msg->err = msg->conn->last_err;
@ -925,13 +925,13 @@ do_bind(struct api_msg_msg *msg)
#if LWIP_TCP #if LWIP_TCP
/** /**
* TCP callback function if a connection (opened by tcp_connect/do_connect) has * TCP callback function if a connection (opened by tcp_connect/lwip_netconn_do_connect) has
* been established (or reset by the remote host). * been established (or reset by the remote host).
* *
* @see tcp.h (struct tcp_pcb.connected) for parameters and return values * @see tcp.h (struct tcp_pcb.connected) for parameters and return values
*/ */
static err_t static err_t
do_connected(void *arg, struct tcp_pcb *pcb, err_t err) lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
{ {
struct netconn *conn; struct netconn *conn;
int was_blocking; int was_blocking;
@ -978,7 +978,7 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
* the IP address and port to connect to * the IP address and port to connect to
*/ */
void void
do_connect(struct api_msg_msg *msg) lwip_netconn_do_connect(struct api_msg_msg *msg)
{ {
if (msg->conn->pcb.tcp == NULL) { if (msg->conn->pcb.tcp == NULL) {
/* This may happen when calling netconn_connect() a second time */ /* This may happen when calling netconn_connect() a second time */
@ -1003,7 +1003,7 @@ do_connect(struct api_msg_msg *msg)
} else { } else {
setup_tcp(msg->conn); setup_tcp(msg->conn);
msg->err = tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->err = tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr,
msg->msg.bc.port, do_connected); msg->msg.bc.port, lwip_netconn_do_connected);
if (msg->err == ERR_OK) { if (msg->err == ERR_OK) {
u8_t non_blocking = netconn_is_nonblocking(msg->conn); u8_t non_blocking = netconn_is_nonblocking(msg->conn);
msg->conn->state = NETCONN_CONNECT; msg->conn->state = NETCONN_CONNECT;
@ -1012,7 +1012,7 @@ do_connect(struct api_msg_msg *msg)
msg->err = ERR_INPROGRESS; msg->err = ERR_INPROGRESS;
} else { } else {
msg->conn->current_msg = msg; msg->conn->current_msg = msg;
/* sys_sem_signal() is called from do_connected (or err_tcp()), /* sys_sem_signal() is called from lwip_netconn_do_connected (or err_tcp()),
* when the connection is established! */ * when the connection is established! */
return; return;
} }
@ -1036,7 +1036,7 @@ do_connect(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection to disconnect * @param msg the api_msg_msg pointing to the connection to disconnect
*/ */
void void
do_disconnect(struct api_msg_msg *msg) lwip_netconn_do_disconnect(struct api_msg_msg *msg)
{ {
#if LWIP_UDP #if LWIP_UDP
if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) { if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) {
@ -1058,7 +1058,7 @@ do_disconnect(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_listen(struct api_msg_msg *msg) lwip_netconn_do_listen(struct api_msg_msg *msg)
{ {
if (ERR_IS_FATAL(msg->conn->last_err)) { if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err; msg->err = msg->conn->last_err;
@ -1114,7 +1114,7 @@ do_listen(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_send(struct api_msg_msg *msg) lwip_netconn_do_send(struct api_msg_msg *msg)
{ {
if (ERR_IS_FATAL(msg->conn->last_err)) { if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err; msg->err = msg->conn->last_err;
@ -1167,7 +1167,7 @@ do_send(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_recv(struct api_msg_msg *msg) lwip_netconn_do_recv(struct api_msg_msg *msg)
{ {
msg->err = ERR_OK; msg->err = ERR_OK;
if (msg->conn->pcb.tcp != NULL) { if (msg->conn->pcb.tcp != NULL) {
@ -1192,7 +1192,7 @@ do_recv(struct api_msg_msg *msg)
/** /**
* See if more data needs to be written from a previous call to netconn_write. * See if more data needs to be written from a previous call to netconn_write.
* Called initially from do_write. If the first call can't send all data * Called initially from lwip_netconn_do_write. If the first call can't send all data
* (because of low memory or empty send-buffer), this function is called again * (because of low memory or empty send-buffer), this function is called again
* from sent_tcp() or poll_tcp() to send more data. If all data is sent, the * from sent_tcp() or poll_tcp() to send more data. If all data is sent, the
* blocking application thread (waiting in netconn_write) is released. * blocking application thread (waiting in netconn_write) is released.
@ -1202,7 +1202,7 @@ do_recv(struct api_msg_msg *msg)
* ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished * ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished
*/ */
static err_t static err_t
do_writemore(struct netconn *conn) lwip_netconn_do_writemore(struct netconn *conn)
{ {
err_t err; err_t err;
void *dataptr; void *dataptr;
@ -1263,7 +1263,7 @@ do_writemore(struct netconn *conn)
apiflags |= TCP_WRITE_FLAG_MORE; apiflags |= TCP_WRITE_FLAG_MORE;
} }
} }
LWIP_ASSERT("do_writemore: invalid length!", ((conn->write_offset + len) <= conn->current_msg->msg.w.len)); LWIP_ASSERT("lwip_netconn_do_writemore: invalid length!", ((conn->write_offset + len) <= conn->current_msg->msg.w.len));
err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags); err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags);
/* if OK or memory error, check available space */ /* if OK or memory error, check available space */
if ((err == ERR_OK) || (err == ERR_MEM)) { if ((err == ERR_OK) || (err == ERR_MEM)) {
@ -1337,7 +1337,7 @@ err_mem:
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_write(struct api_msg_msg *msg) lwip_netconn_do_write(struct api_msg_msg *msg)
{ {
if (ERR_IS_FATAL(msg->conn->last_err)) { if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err; msg->err = msg->conn->last_err;
@ -1349,7 +1349,7 @@ do_write(struct api_msg_msg *msg)
msg->err = ERR_INPROGRESS; msg->err = ERR_INPROGRESS;
} else if (msg->conn->pcb.tcp != NULL) { } else if (msg->conn->pcb.tcp != NULL) {
msg->conn->state = NETCONN_WRITE; msg->conn->state = NETCONN_WRITE;
/* set all the variables used by do_writemore */ /* set all the variables used by lwip_netconn_do_writemore */
LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL &&
msg->conn->write_offset == 0); msg->conn->write_offset == 0);
LWIP_ASSERT("msg->msg.w.len != 0", msg->msg.w.len != 0); LWIP_ASSERT("msg->msg.w.len != 0", msg->msg.w.len != 0);
@ -1357,7 +1357,7 @@ do_write(struct api_msg_msg *msg)
msg->conn->write_offset = 0; msg->conn->write_offset = 0;
#if LWIP_TCPIP_CORE_LOCKING #if LWIP_TCPIP_CORE_LOCKING
msg->conn->flags &= ~NETCONN_FLAG_WRITE_DELAYED; msg->conn->flags &= ~NETCONN_FLAG_WRITE_DELAYED;
if (do_writemore(msg->conn) != ERR_OK) { if (lwip_netconn_do_writemore(msg->conn) != ERR_OK) {
LWIP_ASSERT("state!", msg->conn->state == NETCONN_WRITE); LWIP_ASSERT("state!", msg->conn->state == NETCONN_WRITE);
UNLOCK_TCPIP_CORE(); UNLOCK_TCPIP_CORE();
sys_arch_sem_wait(&msg->conn->op_completed, 0); sys_arch_sem_wait(&msg->conn->op_completed, 0);
@ -1365,10 +1365,10 @@ do_write(struct api_msg_msg *msg)
LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE); LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE);
} }
#else /* LWIP_TCPIP_CORE_LOCKING */ #else /* LWIP_TCPIP_CORE_LOCKING */
do_writemore(msg->conn); lwip_netconn_do_writemore(msg->conn);
#endif /* LWIP_TCPIP_CORE_LOCKING */ #endif /* LWIP_TCPIP_CORE_LOCKING */
/* for both cases: if do_writemore was called, don't ACK the APIMSG /* for both cases: if lwip_netconn_do_writemore was called, don't ACK the APIMSG
since do_writemore ACKs it! */ since lwip_netconn_do_writemore ACKs it! */
return; return;
} else { } else {
msg->err = ERR_CONN; msg->err = ERR_CONN;
@ -1392,7 +1392,7 @@ do_write(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_getaddr(struct api_msg_msg *msg) lwip_netconn_do_getaddr(struct api_msg_msg *msg)
{ {
if (msg->conn->pcb.ip != NULL) { if (msg->conn->pcb.ip != NULL) {
if (msg->msg.ad.local) { if (msg->msg.ad.local) {
@ -1449,7 +1449,7 @@ do_getaddr(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_close(struct api_msg_msg *msg) lwip_netconn_do_close(struct api_msg_msg *msg)
{ {
#if LWIP_TCP #if LWIP_TCP
/* @todo: abort running write/connect? */ /* @todo: abort running write/connect? */
@ -1471,8 +1471,8 @@ do_close(struct api_msg_msg *msg)
msg->conn->write_offset == 0); msg->conn->write_offset == 0);
msg->conn->state = NETCONN_CLOSE; msg->conn->state = NETCONN_CLOSE;
msg->conn->current_msg = msg; msg->conn->current_msg = msg;
do_close_internal(msg->conn); lwip_netconn_do_close_internal(msg->conn);
/* for tcp netconns, do_close_internal ACKs the message */ /* for tcp netconns, lwip_netconn_do_close_internal ACKs the message */
return; return;
} }
} else } else
@ -1491,7 +1491,7 @@ do_close(struct api_msg_msg *msg)
* @param msg the api_msg_msg pointing to the connection * @param msg the api_msg_msg pointing to the connection
*/ */
void void
do_join_leave_group(struct api_msg_msg *msg) lwip_netconn_do_join_leave_group(struct api_msg_msg *msg)
{ {
if (ERR_IS_FATAL(msg->conn->last_err)) { if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err; msg->err = msg->conn->last_err;
@ -1543,7 +1543,7 @@ do_join_leave_group(struct api_msg_msg *msg)
* signaling the semaphore. * signaling the semaphore.
*/ */
static void static void
do_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) lwip_netconn_do_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{ {
struct dns_api_msg *msg = (struct dns_api_msg*)arg; struct dns_api_msg *msg = (struct dns_api_msg*)arg;
@ -1569,11 +1569,11 @@ do_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
* @param arg the dns_api_msg pointing to the query * @param arg the dns_api_msg pointing to the query
*/ */
void void
do_gethostbyname(void *arg) lwip_netconn_do_gethostbyname(void *arg)
{ {
struct dns_api_msg *msg = (struct dns_api_msg*)arg; struct dns_api_msg *msg = (struct dns_api_msg*)arg;
*msg->err = dns_gethostbyname(msg->name, msg->addr, do_dns_found, msg); *msg->err = dns_gethostbyname(msg->name, msg->addr, lwip_netconn_do_dns_found, msg);
if (*msg->err != ERR_INPROGRESS) { if (*msg->err != ERR_INPROGRESS) {
/* on error or immediate success, wake up the application /* on error or immediate success, wake up the application
* task waiting in netconn_gethostbyname */ * task waiting in netconn_gethostbyname */

View File

@ -41,8 +41,8 @@
/** /**
* Call netif_add() inside the tcpip_thread context. * Call netif_add() inside the tcpip_thread context.
*/ */
void static void
do_netifapi_netif_add(struct netifapi_msg_msg *msg) netifapi_do_netif_add(struct netifapi_msg_msg *msg)
{ {
if (!netif_add( msg->netif, if (!netif_add( msg->netif,
msg->msg.add.ipaddr, msg->msg.add.ipaddr,
@ -61,8 +61,8 @@ do_netifapi_netif_add(struct netifapi_msg_msg *msg)
/** /**
* Call netif_set_addr() inside the tcpip_thread context. * Call netif_set_addr() inside the tcpip_thread context.
*/ */
void static void
do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg) netifapi_do_netif_set_addr(struct netifapi_msg_msg *msg)
{ {
netif_set_addr( msg->netif, netif_set_addr( msg->netif,
msg->msg.add.ipaddr, msg->msg.add.ipaddr,
@ -76,8 +76,8 @@ do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg)
* Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
* tcpip_thread context. * tcpip_thread context.
*/ */
void static void
do_netifapi_netif_common(struct netifapi_msg_msg *msg) netifapi_do_netif_common(struct netifapi_msg_msg *msg)
{ {
if (msg->msg.common.errtfunc != NULL) { if (msg->msg.common.errtfunc != NULL) {
msg->err = msg->msg.common.errtfunc(msg->netif); msg->err = msg->msg.common.errtfunc(msg->netif);
@ -104,7 +104,7 @@ netifapi_netif_add(struct netif *netif,
netif_input_fn input) netif_input_fn input)
{ {
struct netifapi_msg msg; struct netifapi_msg msg;
msg.function = do_netifapi_netif_add; msg.function = netifapi_do_netif_add;
msg.msg.netif = netif; msg.msg.netif = netif;
msg.msg.msg.add.ipaddr = ipaddr; msg.msg.msg.add.ipaddr = ipaddr;
msg.msg.msg.add.netmask = netmask; msg.msg.msg.add.netmask = netmask;
@ -129,7 +129,7 @@ netifapi_netif_set_addr(struct netif *netif,
ip_addr_t *gw) ip_addr_t *gw)
{ {
struct netifapi_msg msg; struct netifapi_msg msg;
msg.function = do_netifapi_netif_set_addr; msg.function = netifapi_do_netif_set_addr;
msg.msg.netif = netif; msg.msg.netif = netif;
msg.msg.msg.add.ipaddr = ipaddr; msg.msg.msg.add.ipaddr = ipaddr;
msg.msg.msg.add.netmask = netmask; msg.msg.msg.add.netmask = netmask;
@ -149,7 +149,7 @@ netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
netifapi_errt_fn errtfunc) netifapi_errt_fn errtfunc)
{ {
struct netifapi_msg msg; struct netifapi_msg msg;
msg.function = do_netifapi_netif_common; msg.function = netifapi_do_netif_common;
msg.msg.netif = netif; msg.msg.netif = netif;
msg.msg.msg.common.voidfunc = voidfunc; msg.msg.msg.common.voidfunc = voidfunc;
msg.msg.msg.common.errtfunc = errtfunc; msg.msg.msg.common.errtfunc = errtfunc;

View File

@ -67,24 +67,24 @@ struct api_msg_msg {
err_t err; err_t err;
/** Depending on the executed function, one of these union members is used */ /** Depending on the executed function, one of these union members is used */
union { union {
/** used for do_send */ /** used for lwip_netconn_do_send */
struct netbuf *b; struct netbuf *b;
/** used for do_newconn */ /** used for lwip_netconn_do_newconn */
struct { struct {
u8_t proto; u8_t proto;
} n; } n;
/** used for do_bind and do_connect */ /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */
struct { struct {
ip_addr_t *ipaddr; ip_addr_t *ipaddr;
u16_t port; u16_t port;
} bc; } bc;
/** used for do_getaddr */ /** used for lwip_netconn_do_getaddr */
struct { struct {
ipX_addr_t *ipaddr; ipX_addr_t *ipaddr;
u16_t *port; u16_t *port;
u8_t local; u8_t local;
} ad; } ad;
/** used for do_write */ /** used for lwip_netconn_do_write */
struct { struct {
const void *dataptr; const void *dataptr;
size_t len; size_t len;
@ -93,16 +93,16 @@ struct api_msg_msg {
u32_t time_started; u32_t time_started;
#endif /* LWIP_SO_SNDTIMEO */ #endif /* LWIP_SO_SNDTIMEO */
} w; } w;
/** used for do_recv */ /** used for lwip_netconn_do_recv */
struct { struct {
u32_t len; u32_t len;
} r; } r;
/** used for do_close (/shutdown) */ /** used for lwip_netconn_do_close (/shutdown) */
struct { struct {
u8_t shut; u8_t shut;
} sd; } sd;
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
/** used for do_join_leave_group */ /** used for lwip_netconn_do_join_leave_group */
struct { struct {
ipX_addr_t *multiaddr; ipX_addr_t *multiaddr;
ipX_addr_t *netif_addr; ipX_addr_t *netif_addr;
@ -128,9 +128,9 @@ struct api_msg {
}; };
#if LWIP_DNS #if LWIP_DNS
/** As do_gethostbyname requires more arguments but doesn't require a netconn, /** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn,
it has its own struct (to avoid struct api_msg getting bigger than necessary). it has its own struct (to avoid struct api_msg getting bigger than necessary).
do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
(see netconn_gethostbyname). */ (see netconn_gethostbyname). */
struct dns_api_msg { struct dns_api_msg {
/** Hostname to query or dotted IP address string */ /** Hostname to query or dotted IP address string */
@ -145,24 +145,24 @@ struct dns_api_msg {
}; };
#endif /* LWIP_DNS */ #endif /* LWIP_DNS */
void do_newconn ( struct api_msg_msg *msg); void lwip_netconn_do_newconn ( struct api_msg_msg *msg);
void do_delconn ( struct api_msg_msg *msg); void lwip_netconn_do_delconn ( struct api_msg_msg *msg);
void do_bind ( struct api_msg_msg *msg); void lwip_netconn_do_bind ( struct api_msg_msg *msg);
void do_connect ( struct api_msg_msg *msg); void lwip_netconn_do_connect ( struct api_msg_msg *msg);
void do_disconnect ( struct api_msg_msg *msg); void lwip_netconn_do_disconnect ( struct api_msg_msg *msg);
void do_listen ( struct api_msg_msg *msg); void lwip_netconn_do_listen ( struct api_msg_msg *msg);
void do_send ( struct api_msg_msg *msg); void lwip_netconn_do_send ( struct api_msg_msg *msg);
void do_recv ( struct api_msg_msg *msg); void lwip_netconn_do_recv ( struct api_msg_msg *msg);
void do_write ( struct api_msg_msg *msg); void lwip_netconn_do_write ( struct api_msg_msg *msg);
void do_getaddr ( struct api_msg_msg *msg); void lwip_netconn_do_getaddr ( struct api_msg_msg *msg);
void do_close ( struct api_msg_msg *msg); void lwip_netconn_do_close ( struct api_msg_msg *msg);
void do_shutdown ( struct api_msg_msg *msg); void lwip_netconn_do_shutdown ( struct api_msg_msg *msg);
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
void do_join_leave_group( struct api_msg_msg *msg); void lwip_netconn_do_join_leave_group( struct api_msg_msg *msg);
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
#if LWIP_DNS #if LWIP_DNS
void do_gethostbyname(void *arg); void lwip_netconn_do_gethostbyname(void *arg);
#endif /* LWIP_DNS */ #endif /* LWIP_DNS */
struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);