mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-21 00:39:58 +00:00
netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the common function to reduce a little bit the footprint (for all functions using only the "netif" parameter).
This commit is contained in:
parent
949efb414a
commit
79c00be516
@ -19,6 +19,11 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-10-05 Frédéric Bernon
|
||||||
|
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
|
||||||
|
common function to reduce a little bit the footprint (for all functions using
|
||||||
|
only the "netif" parameter).
|
||||||
|
|
||||||
2007-10-03 Frédéric Bernon
|
2007-10-03 Frédéric Bernon
|
||||||
* netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down,
|
* 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
|
netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce
|
||||||
|
@ -39,19 +39,40 @@
|
|||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* call the "do_function" in a thread-safe way by running that function inside the
|
* Call netif_add() inside the tcpip_thread context.
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note use only for "do_netifapi" functions where there is only netif parameter.
|
|
||||||
*/
|
*/
|
||||||
err_t
|
void
|
||||||
netifapi_netif_common(struct netif *netif, void (* function)(struct netifapi_msg_msg *msg))
|
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
||||||
{
|
{
|
||||||
struct netifapi_msg msg;
|
if (!netif_add( msg->netif,
|
||||||
msg.function = function;
|
msg->msg.add.ipaddr,
|
||||||
msg.msg.netif = netif;
|
msg->msg.add.netmask,
|
||||||
TCPIP_NETIFAPI(&msg);
|
msg->msg.add.gw,
|
||||||
return msg.msg.err;
|
msg->msg.add.state,
|
||||||
|
msg->msg.add.init,
|
||||||
|
msg->msg.add.input)) {
|
||||||
|
msg->err = ERR_IF;
|
||||||
|
} else {
|
||||||
|
msg->err = ERR_OK;
|
||||||
|
}
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
if (msg->msg.common.errtfunc!=NULL) {
|
||||||
|
msg->err =
|
||||||
|
msg->msg.common.errtfunc(msg->netif);
|
||||||
|
} else {
|
||||||
|
msg->err = ERR_OK;
|
||||||
|
msg->msg.common.voidfunc(msg->netif);
|
||||||
|
}
|
||||||
|
TCPIP_NETIFAPI_ACK(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,8 +91,8 @@ netifapi_netif_add(struct netif *netif,
|
|||||||
err_t (* input)(struct pbuf *p, struct netif *netif))
|
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||||
{
|
{
|
||||||
struct netifapi_msg msg;
|
struct netifapi_msg msg;
|
||||||
msg.function = do_netifapi_netif_add;
|
msg.function = do_netifapi_netif_add;
|
||||||
msg.msg.netif = netif;
|
msg.msg.netif = netif;
|
||||||
msg.msg.msg.add.ipaddr = ipaddr;
|
msg.msg.msg.add.ipaddr = ipaddr;
|
||||||
msg.msg.msg.add.netmask = netmask;
|
msg.msg.msg.add.netmask = netmask;
|
||||||
msg.msg.msg.add.gw = gw;
|
msg.msg.msg.add.gw = gw;
|
||||||
@ -83,100 +104,23 @@ netifapi_netif_add(struct netif *netif,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo comment
|
* call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
|
||||||
|
* way by running that function inside the tcpip_thread context.
|
||||||
|
*
|
||||||
|
* @note use only for functions where there is only "netif" parameter.
|
||||||
*/
|
*/
|
||||||
void
|
err_t
|
||||||
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
netifapi_netif_common( struct netif *netif,
|
||||||
{
|
void (* voidfunc)(struct netif *netif),
|
||||||
msg->err = ERR_OK;
|
err_t (* errtfunc)(struct netif *netif) )
|
||||||
if (!netif_add( msg->netif,
|
{
|
||||||
msg->msg.add.ipaddr,
|
struct netifapi_msg msg;
|
||||||
msg->msg.add.netmask,
|
msg.function = do_netifapi_netif_common;
|
||||||
msg->msg.add.gw,
|
msg.msg.netif = netif;
|
||||||
msg->msg.add.state,
|
msg.msg.msg.common.voidfunc = voidfunc;
|
||||||
msg->msg.add.init,
|
msg.msg.msg.common.errtfunc = errtfunc;
|
||||||
msg->msg.add.input)) {
|
TCPIP_NETIFAPI(&msg);
|
||||||
msg->err = ERR_IF;
|
return msg.msg.err;
|
||||||
}
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo comment
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
do_netifapi_netif_remove( struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
msg->err = ERR_OK;
|
|
||||||
netif_remove(msg->netif);
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
do_netifapi_dhcp_start( struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
msg->err = dhcp_start(msg->netif);
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo comment
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
do_netifapi_dhcp_stop( struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
msg->err = ERR_OK;
|
|
||||||
dhcp_stop(msg->netif);
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
#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 */
|
||||||
|
@ -53,9 +53,13 @@ struct netifapi_msg_msg {
|
|||||||
struct ip_addr *netmask;
|
struct ip_addr *netmask;
|
||||||
struct ip_addr *gw;
|
struct ip_addr *gw;
|
||||||
void *state;
|
void *state;
|
||||||
err_t (* init)(struct netif *netif);
|
err_t (* init) (struct netif *netif);
|
||||||
err_t (* input)(struct pbuf *p, struct netif *netif);
|
err_t (* input)(struct pbuf *p, struct netif *netif);
|
||||||
} add;
|
} add;
|
||||||
|
struct {
|
||||||
|
void (* voidfunc)(struct netif *netif);
|
||||||
|
err_t (* errtfunc)(struct netif *netif);
|
||||||
|
} common;
|
||||||
} msg;
|
} msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,8 +70,6 @@ struct netifapi_msg {
|
|||||||
|
|
||||||
|
|
||||||
/* API for application */
|
/* API for application */
|
||||||
err_t netifapi_netif_common ( struct netif *netif, void (* function)(struct netifapi_msg_msg *msg));
|
|
||||||
|
|
||||||
err_t netifapi_netif_add ( struct netif *netif,
|
err_t netifapi_netif_add ( struct netif *netif,
|
||||||
struct ip_addr *ipaddr,
|
struct ip_addr *ipaddr,
|
||||||
struct ip_addr *netmask,
|
struct ip_addr *netmask,
|
||||||
@ -76,29 +78,18 @@ err_t netifapi_netif_add ( struct netif *netif,
|
|||||||
err_t (* init)(struct netif *netif),
|
err_t (* init)(struct netif *netif),
|
||||||
err_t (* input)(struct pbuf *p, 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)
|
err_t netifapi_netif_common ( struct netif *netif,
|
||||||
#define netifapi_netif_set_up(n) netifapi_netif_common(n, do_netifapi_netif_set_up)
|
void (* voidfunc)(struct netif *netif),
|
||||||
#define netifapi_netif_set_down(n) netifapi_netif_common(n, do_netifapi_netif_set_down)
|
err_t (* errtfunc)(struct netif *netif) );
|
||||||
#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)
|
|
||||||
|
|
||||||
|
|
||||||
/* API for tcpip_thread */
|
|
||||||
void do_netifapi_netif_add ( 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
|
|
||||||
void do_netifapi_dhcp_start ( struct netifapi_msg_msg *msg);
|
|
||||||
void do_netifapi_dhcp_stop ( struct netifapi_msg_msg *msg);
|
|
||||||
#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 */
|
|
||||||
|
|
||||||
|
#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
|
||||||
|
#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
|
||||||
|
#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
|
||||||
|
#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
|
||||||
|
#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
|
||||||
|
#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
|
||||||
|
#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
|
||||||
|
#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user