++ 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
* ip4.c: fixed bug #35927: missing refragmentaion in ip_forward
err_t err;
msg.msg.msg.n.proto = proto;
msg.msg.conn = conn;
- TCPIP_APIMSG((&msg), do_newconn, err);
+ TCPIP_APIMSG((&msg), lwip_netconn_do_newconn, err);
if (err != ERR_OK) {
LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL);
LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed));
return ERR_OK;
}
- msg.function = do_delconn;
+ msg.function = lwip_netconn_do_delconn;
msg.msg.conn = conn;
tcpip_apimsg(&msg);
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;
}
msg.msg.msg.ad.ipaddr = ip_2_ipX(addr);
msg.msg.msg.ad.port = port;
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);
return err;
msg.msg.conn = conn;
msg.msg.msg.bc.ipaddr = addr;
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);
return err;
{
/* The TCP version waits for the connect to succeed,
so always needs to use message passing. */
- msg.function = do_connect;
+ msg.function = lwip_netconn_do_connect;
err = tcpip_apimsg(&msg);
}
#endif /* LWIP_TCP */
#if (LWIP_UDP || LWIP_RAW)
{
/* 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) */
LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;);
msg.msg.conn = conn;
- TCPIP_APIMSG(&msg, do_disconnect, err);
+ TCPIP_APIMSG(&msg, lwip_netconn_do_disconnect, err);
NETCONN_SET_SAFE_ERR(conn, err);
return err;
#if TCP_LISTEN_BACKLOG
msg.msg.msg.lb.backlog = 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);
return err;
#if TCP_LISTEN_BACKLOG
/* Let the stack know that we have accepted the connection. */
msg.msg.conn = conn;
- /* don't care for the return value of do_recv */
- TCPIP_APIMSG_NOERR(&msg, do_recv);
+ /* don't care for the return value of lwip_netconn_do_recv */
+ TCPIP_APIMSG_NOERR(&msg, lwip_netconn_do_recv);
#endif /* TCP_LISTEN_BACKLOG */
*new_conn = newconn;
} else {
msg.msg.msg.r.len = 1;
}
- /* don't care for the return value of do_recv */
- TCPIP_APIMSG_NOERR(&msg, do_recv);
+ /* don't care for the return value of lwip_netconn_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 */
(to prevent multiple thread-switches). */
msg.msg.conn = conn;
msg.msg.msg.r.len = length;
- /* don't care for the return value of do_recv */
- TCPIP_APIMSG_NOERR(&msg, do_recv);
+ /* don't care for the return value of lwip_netconn_do_recv */
+ TCPIP_APIMSG_NOERR(&msg, lwip_netconn_do_recv);
}
#else /* LWIP_TCP */
LWIP_UNUSED_ARG(conn);
LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len));
msg.msg.conn = conn;
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);
return err;
/* 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
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 (dontblock
#if LWIP_SO_SNDTIMEO
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;
/* shutting down both ends is the same as closing */
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 */
err = tcpip_apimsg(&msg);
msg.msg.msg.jl.multiaddr = ip_2_ipX(multiaddr);
msg.msg.msg.jl.netif_addr = ip_2_ipX(netif_addr);
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);
return err;
msg.err = &err;
msg.sem = &sem;
- tcpip_callback(do_gethostbyname, &msg);
+ tcpip_callback(lwip_netconn_do_gethostbyname, &msg);
sys_sem_wait(&sem);
sys_sem_free(&sem);
/* forward declarations */
#if LWIP_TCP
-static err_t do_writemore(struct netconn *conn);
-static void do_close_internal(struct netconn *conn);
+static err_t lwip_netconn_do_writemore(struct netconn *conn);
+static void lwip_netconn_do_close_internal(struct netconn *conn);
#endif
#if LWIP_RAW
LWIP_ASSERT("conn != NULL", (conn != NULL));
if (conn->state == NETCONN_WRITE) {
- do_writemore(conn);
+ lwip_netconn_do_writemore(conn);
} else if (conn->state == NETCONN_CLOSE) {
- do_close_internal(conn);
+ lwip_netconn_do_close_internal(conn);
}
/* @todo: implement connect timeout here? */
LWIP_ASSERT("conn != NULL", (conn != NULL));
if (conn->state == NETCONN_WRITE) {
- do_writemore(conn);
+ lwip_netconn_do_writemore(conn);
} else if (conn->state == NETCONN_CLOSE) {
- do_close_internal(conn);
+ lwip_netconn_do_close_internal(conn);
}
if (conn) {
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
(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! */
int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn);
SET_NONBLOCKING_CONNECT(conn, 0);
/**
* 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
* @return msg->conn->err, but the return value is currently ignored
* @param msg the api_msg_msg describing the connection type
*/
void
-do_newconn(struct api_msg_msg *msg)
+lwip_netconn_do_newconn(struct api_msg_msg *msg)
{
msg->err = ERR_OK;
if(msg->conn->pcb.tcp == NULL) {
* @param conn the TCP netconn to close
*/
static void
-do_close_internal(struct netconn *conn)
+lwip_netconn_do_close_internal(struct netconn *conn)
{
err_t err;
u8_t shut, shut_rx, shut_tx, close;
* @param msg the api_msg_msg pointing to the connection
*/
void
-do_delconn(struct api_msg_msg *msg)
+lwip_netconn_do_delconn(struct api_msg_msg *msg)
{
/* @todo TCP: abort running write/connect? */
if ((msg->conn->state != NETCONN_NONE) &&
msg->conn->state = NETCONN_CLOSE;
msg->msg.sd.shut = NETCONN_SHUT_RDWR;
msg->conn->current_msg = msg;
- do_close_internal(msg->conn);
- /* API_EVENT is called inside do_close_internal, before releasing
+ lwip_netconn_do_close_internal(msg->conn);
+ /* API_EVENT is called inside lwip_netconn_do_close_internal, before releasing
the application thread, so we can return at this point! */
return;
#endif /* LWIP_TCP */
* the IP address and port to bind to
*/
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)) {
msg->err = msg->conn->last_err;
#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).
*
* @see tcp.h (struct tcp_pcb.connected) for parameters and return values
*/
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;
int was_blocking;
* the IP address and port to connect to
*/
void
-do_connect(struct api_msg_msg *msg)
+lwip_netconn_do_connect(struct api_msg_msg *msg)
{
if (msg->conn->pcb.tcp == NULL) {
/* This may happen when calling netconn_connect() a second time */
} else {
setup_tcp(msg->conn);
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) {
u8_t non_blocking = netconn_is_nonblocking(msg->conn);
msg->conn->state = NETCONN_CONNECT;
msg->err = ERR_INPROGRESS;
} else {
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! */
return;
}
* @param msg the api_msg_msg pointing to the connection to disconnect
*/
void
-do_disconnect(struct api_msg_msg *msg)
+lwip_netconn_do_disconnect(struct api_msg_msg *msg)
{
#if LWIP_UDP
if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) {
* @param msg the api_msg_msg pointing to the connection
*/
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)) {
msg->err = msg->conn->last_err;
* @param msg the api_msg_msg pointing to the connection
*/
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)) {
msg->err = msg->conn->last_err;
* @param msg the api_msg_msg pointing to the connection
*/
void
-do_recv(struct api_msg_msg *msg)
+lwip_netconn_do_recv(struct api_msg_msg *msg)
{
msg->err = ERR_OK;
if (msg->conn->pcb.tcp != NULL) {
/**
* 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
* 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.
* ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished
*/
static err_t
-do_writemore(struct netconn *conn)
+lwip_netconn_do_writemore(struct netconn *conn)
{
err_t err;
void *dataptr;
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);
/* if OK or memory error, check available space */
if ((err == ERR_OK) || (err == ERR_MEM)) {
* @param msg the api_msg_msg pointing to the connection
*/
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)) {
msg->err = msg->conn->last_err;
msg->err = ERR_INPROGRESS;
} else if (msg->conn->pcb.tcp != NULL) {
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 &&
msg->conn->write_offset == 0);
LWIP_ASSERT("msg->msg.w.len != 0", msg->msg.w.len != 0);
msg->conn->write_offset = 0;
#if LWIP_TCPIP_CORE_LOCKING
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);
UNLOCK_TCPIP_CORE();
sys_arch_sem_wait(&msg->conn->op_completed, 0);
LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE);
}
#else /* LWIP_TCPIP_CORE_LOCKING */
- do_writemore(msg->conn);
+ lwip_netconn_do_writemore(msg->conn);
#endif /* LWIP_TCPIP_CORE_LOCKING */
- /* for both cases: if do_writemore was called, don't ACK the APIMSG
- since do_writemore ACKs it! */
+ /* for both cases: if lwip_netconn_do_writemore was called, don't ACK the APIMSG
+ since lwip_netconn_do_writemore ACKs it! */
return;
} else {
msg->err = ERR_CONN;
* @param msg the api_msg_msg pointing to the connection
*/
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->msg.ad.local) {
* @param msg the api_msg_msg pointing to the connection
*/
void
-do_close(struct api_msg_msg *msg)
+lwip_netconn_do_close(struct api_msg_msg *msg)
{
#if LWIP_TCP
/* @todo: abort running write/connect? */
msg->conn->write_offset == 0);
msg->conn->state = NETCONN_CLOSE;
msg->conn->current_msg = msg;
- do_close_internal(msg->conn);
- /* for tcp netconns, do_close_internal ACKs the message */
+ lwip_netconn_do_close_internal(msg->conn);
+ /* for tcp netconns, lwip_netconn_do_close_internal ACKs the message */
return;
}
} else
* @param msg the api_msg_msg pointing to the connection
*/
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)) {
msg->err = msg->conn->last_err;
* signaling the semaphore.
*/
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;
* @param arg the dns_api_msg pointing to the query
*/
void
-do_gethostbyname(void *arg)
+lwip_netconn_do_gethostbyname(void *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) {
/* on error or immediate success, wake up the application
* task waiting in netconn_gethostbyname */
/**
* Call netif_add() inside the tcpip_thread context.
*/
-void
-do_netifapi_netif_add(struct netifapi_msg_msg *msg)
+static void
+netifapi_do_netif_add(struct netifapi_msg_msg *msg)
{
if (!netif_add( msg->netif,
msg->msg.add.ipaddr,
/**
* Call netif_set_addr() inside the tcpip_thread context.
*/
-void
-do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg)
+static void
+netifapi_do_netif_set_addr(struct netifapi_msg_msg *msg)
{
netif_set_addr( msg->netif,
msg->msg.add.ipaddr,
* Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
* tcpip_thread context.
*/
-void
-do_netifapi_netif_common(struct netifapi_msg_msg *msg)
+static void
+netifapi_do_netif_common(struct netifapi_msg_msg *msg)
{
if (msg->msg.common.errtfunc != NULL) {
msg->err = msg->msg.common.errtfunc(msg->netif);
netif_input_fn input)
{
struct netifapi_msg msg;
- msg.function = do_netifapi_netif_add;
+ msg.function = netifapi_do_netif_add;
msg.msg.netif = netif;
msg.msg.msg.add.ipaddr = ipaddr;
msg.msg.msg.add.netmask = netmask;
ip_addr_t *gw)
{
struct netifapi_msg msg;
- msg.function = do_netifapi_netif_set_addr;
+ msg.function = netifapi_do_netif_set_addr;
msg.msg.netif = netif;
msg.msg.msg.add.ipaddr = ipaddr;
msg.msg.msg.add.netmask = netmask;
netifapi_errt_fn errtfunc)
{
struct netifapi_msg msg;
- msg.function = do_netifapi_netif_common;
+ msg.function = netifapi_do_netif_common;
msg.msg.netif = netif;
msg.msg.msg.common.voidfunc = voidfunc;
msg.msg.msg.common.errtfunc = errtfunc;
err_t err;
/** Depending on the executed function, one of these union members is used */
union {
- /** used for do_send */
+ /** used for lwip_netconn_do_send */
struct netbuf *b;
- /** used for do_newconn */
+ /** used for lwip_netconn_do_newconn */
struct {
u8_t proto;
} n;
- /** used for do_bind and do_connect */
+ /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */
struct {
ip_addr_t *ipaddr;
u16_t port;
} bc;
- /** used for do_getaddr */
+ /** used for lwip_netconn_do_getaddr */
struct {
ipX_addr_t *ipaddr;
u16_t *port;
u8_t local;
} ad;
- /** used for do_write */
+ /** used for lwip_netconn_do_write */
struct {
const void *dataptr;
size_t len;
u32_t time_started;
#endif /* LWIP_SO_SNDTIMEO */
} w;
- /** used for do_recv */
+ /** used for lwip_netconn_do_recv */
struct {
u32_t len;
} r;
- /** used for do_close (/shutdown) */
+ /** used for lwip_netconn_do_close (/shutdown) */
struct {
u8_t shut;
} sd;
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
- /** used for do_join_leave_group */
+ /** used for lwip_netconn_do_join_leave_group */
struct {
ipX_addr_t *multiaddr;
ipX_addr_t *netif_addr;
};
#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).
- 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). */
struct dns_api_msg {
/** Hostname to query or dotted IP address string */
};
#endif /* LWIP_DNS */
-void do_newconn ( struct api_msg_msg *msg);
-void do_delconn ( struct api_msg_msg *msg);
-void do_bind ( struct api_msg_msg *msg);
-void do_connect ( struct api_msg_msg *msg);
-void do_disconnect ( struct api_msg_msg *msg);
-void do_listen ( struct api_msg_msg *msg);
-void do_send ( struct api_msg_msg *msg);
-void do_recv ( struct api_msg_msg *msg);
-void do_write ( struct api_msg_msg *msg);
-void do_getaddr ( struct api_msg_msg *msg);
-void do_close ( struct api_msg_msg *msg);
-void do_shutdown ( struct api_msg_msg *msg);
+void lwip_netconn_do_newconn ( struct api_msg_msg *msg);
+void lwip_netconn_do_delconn ( struct api_msg_msg *msg);
+void lwip_netconn_do_bind ( struct api_msg_msg *msg);
+void lwip_netconn_do_connect ( struct api_msg_msg *msg);
+void lwip_netconn_do_disconnect ( struct api_msg_msg *msg);
+void lwip_netconn_do_listen ( struct api_msg_msg *msg);
+void lwip_netconn_do_send ( struct api_msg_msg *msg);
+void lwip_netconn_do_recv ( struct api_msg_msg *msg);
+void lwip_netconn_do_write ( struct api_msg_msg *msg);
+void lwip_netconn_do_getaddr ( struct api_msg_msg *msg);
+void lwip_netconn_do_close ( struct api_msg_msg *msg);
+void lwip_netconn_do_shutdown ( struct api_msg_msg *msg);
#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) */
#if LWIP_DNS
-void do_gethostbyname(void *arg);
+void lwip_netconn_do_gethostbyname(void *arg);
#endif /* LWIP_DNS */
struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);