mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 04:12:07 +00:00
netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down, netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce a little bit the footprint (for all functions using only the "netif" parameter).
This commit is contained in:
parent
5dd1256769
commit
949efb414a
@ -19,6 +19,11 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-10-03 Frédéric Bernon
|
||||||
|
* netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down,
|
||||||
|
netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce
|
||||||
|
a little bit the footprint (for all functions using only the "netif" parameter).
|
||||||
|
|
||||||
2007-09-15 Frédéric Bernon
|
2007-09-15 Frédéric Bernon
|
||||||
* udp.h, udp.c, sockets.c: Changes for "#20503 IGMP Improvement". Add IP_MULTICAST_IF
|
* udp.h, udp.c, sockets.c: Changes for "#20503 IGMP Improvement". Add IP_MULTICAST_IF
|
||||||
option in socket API, and a new field "multicast_ip" in "struct udp_pcb" (for
|
option in socket API, and a new field "multicast_ip" in "struct udp_pcb" (for
|
||||||
|
@ -38,6 +38,22 @@
|
|||||||
#include "lwip/netifapi.h"
|
#include "lwip/netifapi.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* call the "do_function" in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*
|
||||||
|
* @note use only for "do_netifapi" functions where there is only netif parameter.
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
netifapi_netif_common(struct netif *netif, void (* function)(struct netifapi_msg_msg *msg))
|
||||||
|
{
|
||||||
|
struct netifapi_msg msg;
|
||||||
|
msg.function = function;
|
||||||
|
msg.msg.netif = netif;
|
||||||
|
TCPIP_NETIFAPI(&msg);
|
||||||
|
return msg.msg.err;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call netif_add() in a thread-safe way by running that function inside the
|
* Call netif_add() in a thread-safe way by running that function inside the
|
||||||
* tcpip_thread context.
|
* tcpip_thread context.
|
||||||
@ -67,57 +83,7 @@ netifapi_netif_add(struct netif *netif,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call netif_remove() in a thread-safe way by running that function inside the
|
* @todo comment
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note for params @see netif_remove()
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_netif_remove(struct netif *netif)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_netif_remove;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LWIP_DHCP
|
|
||||||
/**
|
|
||||||
* Call dhcp_start() in a thread-safe way by running that function inside the
|
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note for params @see dhcp_start()
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_dhcp_start(struct netif *netif)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_dhcp_start;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call dhcp_stop() in a thread-safe way by running that function inside the
|
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note for params @see dhcp_stop()
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_dhcp_stop(struct netif *netif)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_dhcp_stop;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
#endif /* LWIP_DHCP */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
||||||
@ -136,7 +102,7 @@ do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* @todo comment
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_netifapi_netif_remove( struct netifapi_msg_msg *msg)
|
do_netifapi_netif_remove( struct netifapi_msg_msg *msg)
|
||||||
@ -146,9 +112,31 @@ do_netifapi_netif_remove( struct netifapi_msg_msg *msg)
|
|||||||
TCPIP_NETIFAPI_ACK(msg);
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LWIP_DHCP
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* @todo comment
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
do_netifapi_netif_set_up( struct netifapi_msg_msg *msg)
|
||||||
|
{
|
||||||
|
msg->err = ERR_OK;
|
||||||
|
netif_set_up(msg->netif);
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo comment
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
do_netifapi_netif_set_down( struct netifapi_msg_msg *msg)
|
||||||
|
{
|
||||||
|
msg->err = ERR_OK;
|
||||||
|
netif_set_down(msg->netif);
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LWIP_DHCP
|
||||||
|
/**
|
||||||
|
* @todo comment
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_netifapi_dhcp_start( struct netifapi_msg_msg *msg)
|
do_netifapi_dhcp_start( struct netifapi_msg_msg *msg)
|
||||||
@ -158,7 +146,7 @@ do_netifapi_dhcp_start( struct netifapi_msg_msg *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* @todo comment
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_netifapi_dhcp_stop( struct netifapi_msg_msg *msg)
|
do_netifapi_dhcp_stop( struct netifapi_msg_msg *msg)
|
||||||
@ -169,4 +157,26 @@ do_netifapi_dhcp_stop( struct netifapi_msg_msg *msg)
|
|||||||
}
|
}
|
||||||
#endif /* LWIP_DHCP */
|
#endif /* LWIP_DHCP */
|
||||||
|
|
||||||
|
#if LWIP_AUTOIP
|
||||||
|
/**
|
||||||
|
* @todo comment
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
do_netifapi_autoip_start( struct netifapi_msg_msg *msg)
|
||||||
|
{
|
||||||
|
msg->err = autoip_start(msg->netif);
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo comment
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
do_netifapi_autoip_stop( struct netifapi_msg_msg *msg)
|
||||||
|
{
|
||||||
|
msg->err = autoip_stop(msg->netif);
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_AUTOIP */
|
||||||
|
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
@ -44,7 +44,7 @@ extern "C" {
|
|||||||
struct netifapi_msg_msg {
|
struct netifapi_msg_msg {
|
||||||
#if !LWIP_TCPIP_CORE_LOCKING
|
#if !LWIP_TCPIP_CORE_LOCKING
|
||||||
sys_sem_t sem;
|
sys_sem_t sem;
|
||||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
err_t err;
|
err_t err;
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
union {
|
union {
|
||||||
@ -66,29 +66,39 @@ struct netifapi_msg {
|
|||||||
|
|
||||||
|
|
||||||
/* API for application */
|
/* API for application */
|
||||||
err_t netifapi_netif_add ( struct netif *netif,
|
err_t netifapi_netif_common ( struct netif *netif, void (* function)(struct netifapi_msg_msg *msg));
|
||||||
struct ip_addr *ipaddr,
|
|
||||||
struct ip_addr *netmask,
|
|
||||||
struct ip_addr *gw,
|
|
||||||
void *state,
|
|
||||||
err_t (* init)(struct netif *netif),
|
|
||||||
err_t (* input)(struct pbuf *p, struct netif *netif) );
|
|
||||||
|
|
||||||
err_t netifapi_netif_remove( struct netif *netif);
|
err_t netifapi_netif_add ( struct netif *netif,
|
||||||
|
struct ip_addr *ipaddr,
|
||||||
|
struct ip_addr *netmask,
|
||||||
|
struct ip_addr *gw,
|
||||||
|
void *state,
|
||||||
|
err_t (* init)(struct netif *netif),
|
||||||
|
err_t (* input)(struct pbuf *p, struct netif *netif) );
|
||||||
|
|
||||||
|
#define netifapi_netif_remove(n) netifapi_netif_common(n, do_netifapi_netif_remove)
|
||||||
|
#define netifapi_netif_set_up(n) netifapi_netif_common(n, do_netifapi_netif_set_up)
|
||||||
|
#define netifapi_netif_set_down(n) netifapi_netif_common(n, do_netifapi_netif_set_down)
|
||||||
|
#define netifapi_dhcp_start(n) netifapi_netif_common(n, do_netifapi_dhcp_start)
|
||||||
|
#define netifapi_dhcp_stop(n) netifapi_netif_common(n, do_netifapi_dhcp_stop)
|
||||||
|
#define netifapi_autoip_start(n) netifapi_netif_common(n, do_netifapi_autoip_start)
|
||||||
|
#define netifapi_autoip_stop(n) netifapi_netif_common(n, do_netifapi_autoip_stop)
|
||||||
|
|
||||||
#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 */
|
/* API for tcpip_thread */
|
||||||
void do_netifapi_netif_add ( struct netifapi_msg_msg *msg);
|
void do_netifapi_netif_add ( struct netifapi_msg_msg *msg);
|
||||||
void do_netifapi_netif_remove( struct netifapi_msg_msg *msg);
|
void do_netifapi_netif_remove ( struct netifapi_msg_msg *msg);
|
||||||
|
void do_netifapi_netif_set_up ( struct netifapi_msg_msg *msg);
|
||||||
|
void do_netifapi_netif_set_down( struct netifapi_msg_msg *msg);
|
||||||
#if LWIP_DHCP
|
#if LWIP_DHCP
|
||||||
void do_netifapi_dhcp_start ( struct netifapi_msg_msg *msg);
|
void do_netifapi_dhcp_start ( struct netifapi_msg_msg *msg);
|
||||||
void do_netifapi_dhcp_stop ( struct netifapi_msg_msg *msg);
|
void do_netifapi_dhcp_stop ( struct netifapi_msg_msg *msg);
|
||||||
#endif /* LWIP_DHCP */
|
#endif /* LWIP_DHCP */
|
||||||
|
#if LWIP_AUTOIP
|
||||||
|
void do_netifapi_autoip_start ( struct netifapi_msg_msg *msg);
|
||||||
|
void do_netifapi_autoip_stop ( struct netifapi_msg_msg *msg);
|
||||||
|
#endif /* LWIP_AUTOIP */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user