tcpip.c: Implement an easier way for TCPIP API calls - client code does not have to deal with semaphores and core locking any more

This commit is contained in:
Dirk Ziegelmeier
2016-03-08 21:26:29 +01:00
parent 5e472badf1
commit 8106413644
2 changed files with 51 additions and 0 deletions

View File

@@ -99,8 +99,21 @@ extern sys_mutex_t lock_tcpip_core;
err_t tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
#endif /* !LWIP_TCPIP_CORE_LOCKING */
struct tcpip_api_call;
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call* call);
struct tcpip_api_call
{
tcpip_api_call_fn function;
#if !LWIP_TCPIP_CORE_LOCKING
sys_sem_t sem;
#endif /* !LWIP_TCPIP_CORE_LOCKING */
err_t err;
};
err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call *call);
enum tcpip_msg_type {
TCPIP_MSG_API,
TCPIP_MSG_API_CALL,
TCPIP_MSG_INPKT,
#if LWIP_TCPIP_TIMEOUT
TCPIP_MSG_TIMEOUT,
@@ -117,6 +130,7 @@ struct tcpip_msg {
tcpip_callback_fn function;
void* msg;
} api;
struct tcpip_api_call *api_call;
struct {
struct pbuf *p;
struct netif *netif;