mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-13 19:57:05 +08:00
netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications in api_lib/api_msg (use pointers and not type with table, etc...)
This commit is contained in:
@@ -40,18 +40,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum netifapi_msg_type {
|
||||
NETIFAPI_MSG_NETIF_ADD,
|
||||
NETIFAPI_MSG_NETIF_REMOVE,
|
||||
#if LWIP_DHCP
|
||||
NETIFAPI_MSG_DHCP_START,
|
||||
NETIFAPI_MSG_DHCP_STOP
|
||||
#endif /* LWIP_DHCP */
|
||||
};
|
||||
|
||||
struct netifapi_msg {
|
||||
enum netifapi_msg_type type;
|
||||
struct netifapi_msg_msg {
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
sys_sem_t sem;
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
err_t err;
|
||||
struct netif *netif;
|
||||
union {
|
||||
@@ -66,6 +58,11 @@ struct netifapi_msg {
|
||||
} msg;
|
||||
};
|
||||
|
||||
struct netifapi_msg {
|
||||
void (* function)(struct netifapi_msg_msg *msg);
|
||||
struct netifapi_msg_msg msg;
|
||||
};
|
||||
|
||||
|
||||
/* API for application */
|
||||
err_t netifapi_netif_add ( struct netif *netif,
|
||||
@@ -78,13 +75,19 @@ err_t netifapi_netif_add ( struct netif *netif,
|
||||
|
||||
err_t netifapi_netif_remove( struct netif *netif);
|
||||
|
||||
err_t netifapi_dhcp_start ( struct netif *netif);
|
||||
|
||||
err_t netifapi_dhcp_stop ( struct netif *netif);
|
||||
|
||||
#if LWIP_DHCP
|
||||
err_t netifapi_dhcp_start ( struct netif *netif);
|
||||
err_t netifapi_dhcp_stop ( struct netif *netif);
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
/* API for tcpip_thread */
|
||||
void netifapi_msg_input(struct netifapi_msg *msg);
|
||||
void do_netifapi_netif_add ( struct netifapi_msg_msg *msg);
|
||||
void do_netifapi_netif_remove( struct netifapi_msg_msg *msg);
|
||||
|
||||
#if LWIP_DHCP
|
||||
void do_netifapi_dhcp_start ( struct netifapi_msg_msg *msg);
|
||||
void do_netifapi_dhcp_stop ( struct netifapi_msg_msg *msg);
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -43,15 +43,19 @@ extern "C" {
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/** The global semaphore to lock the stack. */
|
||||
extern sys_sem_t lock_tcpip_core;
|
||||
#define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core)
|
||||
#define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core)
|
||||
#define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
|
||||
#define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core)
|
||||
#define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core)
|
||||
#define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
|
||||
#define TCPIP_APIMSG_ACK(m)
|
||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
|
||||
#define TCPIP_NETIFAPI_ACK(m)
|
||||
#else
|
||||
#define LOCK_TCPIP_CORE()
|
||||
#define UNLOCK_TCPIP_CORE()
|
||||
#define TCPIP_APIMSG(m) tcpip_apimsg(m)
|
||||
#define TCPIP_APIMSG_ACK(m) sys_mbox_post(m->conn->mbox, NULL)
|
||||
#define TCPIP_APIMSG(m) tcpip_apimsg(m)
|
||||
#define TCPIP_APIMSG_ACK(m) sys_mbox_post(m->conn->mbox, NULL)
|
||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
|
||||
#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
|
||||
@@ -59,15 +63,22 @@ err_t tcpip_apimsg(struct api_msg *apimsg);
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
err_t tcpip_apimsg_lock(struct api_msg *apimsg);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#if ETHARP_TCPIP_INPUT
|
||||
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
||||
#endif /* ETHARP_TCPIP_INPUT */
|
||||
|
||||
#if ETHARP_TCPIP_ETHINPUT
|
||||
err_t tcpip_ethinput(struct pbuf *p, struct netif *inp);
|
||||
#endif /* ETHARP_TCPIP_ETHINPUT */
|
||||
|
||||
#if LWIP_NETIF_API
|
||||
err_t tcpip_netifapi(struct netifapi_msg* netifapimsg);
|
||||
err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_NETIF_API */
|
||||
|
||||
err_t tcpip_callback(void (*f)(void *ctx), void *ctx);
|
||||
|
||||
enum tcpip_msg_type {
|
||||
|
||||
Reference in New Issue
Block a user