|
|
|
|
@ -117,12 +117,6 @@ tcpip_thread(void *arg)
|
|
|
|
|
break; |
|
|
|
|
#endif /* LWIP_NETIF_API */ |
|
|
|
|
|
|
|
|
|
case TCPIP_MSG_CALLBACK: |
|
|
|
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); |
|
|
|
|
msg->msg.cb.function(msg->msg.cb.ctx); |
|
|
|
|
memp_free(MEMP_TCPIP_MSG_API, msg); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
#if LWIP_TCPIP_TIMEOUT |
|
|
|
|
case TCPIP_MSG_TIMEOUT: |
|
|
|
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg)); |
|
|
|
|
@ -136,6 +130,17 @@ tcpip_thread(void *arg)
|
|
|
|
|
break; |
|
|
|
|
#endif /* LWIP_TCPIP_TIMEOUT */ |
|
|
|
|
|
|
|
|
|
case TCPIP_MSG_CALLBACK: |
|
|
|
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); |
|
|
|
|
msg->msg.cb.function(msg->msg.cb.ctx); |
|
|
|
|
memp_free(MEMP_TCPIP_MSG_API, msg); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case TCPIP_MSG_CALLBACK_STATIC: |
|
|
|
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK_STATIC %p\n", (void *)msg)); |
|
|
|
|
msg->msg.cb.function(msg->msg.cb.ctx); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", msg->type)); |
|
|
|
|
LWIP_ASSERT("tcpip_thread: invalid message", 0); |
|
|
|
|
@ -392,6 +397,52 @@ tcpip_netifapi_lock(struct netifapi_msg* netifapimsg)
|
|
|
|
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */ |
|
|
|
|
#endif /* LWIP_NETIF_API */ |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Allocate a structure for a static callback message and initialize it. |
|
|
|
|
* This is intended to be used to send "static" messages from interrupt context. |
|
|
|
|
* |
|
|
|
|
* @param function the function to call |
|
|
|
|
* @param ctx parameter passed to function |
|
|
|
|
* @return a struct pointer to pass to tcpip_trycallback(). |
|
|
|
|
*/ |
|
|
|
|
struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx) |
|
|
|
|
{ |
|
|
|
|
struct tcpip_msg *msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); |
|
|
|
|
if (msg == NULL) { |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
msg->type = TCPIP_MSG_CALLBACK; |
|
|
|
|
msg->msg.cb.function = function; |
|
|
|
|
msg->msg.cb.ctx = ctx; |
|
|
|
|
return (struct tcpip_callback_msg*)msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Free a callback message allocated by tcpip_callbackmsg_new(). |
|
|
|
|
* |
|
|
|
|
* @param msg the message to free |
|
|
|
|
*/ |
|
|
|
|
void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg) |
|
|
|
|
{ |
|
|
|
|
memp_free(MEMP_TCPIP_MSG_API, msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Try to post a callback-message to the tcpip_thread mbox |
|
|
|
|
* This is intended to be used to send "static" messages from interrupt context. |
|
|
|
|
* |
|
|
|
|
* @param msg pointer to the message to post |
|
|
|
|
* @return sys_mbox_trypost() return code |
|
|
|
|
*/ |
|
|
|
|
err_t |
|
|
|
|
tcpip_trycallback(struct tcpip_callback_msg* msg) |
|
|
|
|
{ |
|
|
|
|
if (!sys_mbox_valid(&mbox)) { |
|
|
|
|
return ERR_VAL; |
|
|
|
|
} |
|
|
|
|
return sys_mbox_trypost(&mbox, msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialize this module: |
|
|
|
|
* - initialize all sub modules |
|
|
|
|
|