From e2de2c6bb2322f8413241cab737f0172be808c07 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 27 Oct 2009 20:29:16 +0000 Subject: [PATCH] Added netifapi_netif_set_addr() --- CHANGELOG | 3 +++ src/api/netifapi.c | 36 ++++++++++++++++++++++++++++++++++++ src/include/lwip/netifapi.h | 5 +++++ 3 files changed, 44 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 96afe5ea..d6bd1552 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,9 @@ HISTORY ++ New features: + 2009-10-27 Simon Goldschmidt/Stephan Lesage + * netifapi.c/.h: Added netifapi_netif_set_addr() + 2009-10-07 Simon Goldschmidt/Fabian Koch * api_msg.c, netbuf.c/.h, opt.h: patch #6888: Patch for UDP Netbufs to support dest-addr and dest-port (optional: LWIP_NETBUF_RECVINFO) diff --git a/src/api/netifapi.c b/src/api/netifapi.c index 49183737..57089864 100644 --- a/src/api/netifapi.c +++ b/src/api/netifapi.c @@ -58,6 +58,20 @@ do_netifapi_netif_add( struct netifapi_msg_msg *msg) TCPIP_NETIFAPI_ACK(msg); } +/** + * Call netif_set_addr() inside the tcpip_thread context. + */ +void +do_netifapi_netif_set_addr( struct netifapi_msg_msg *msg) +{ + netif_set_addr( msg->netif, + msg->msg.add.ipaddr, + msg->msg.add.netmask, + msg->msg.add.gw); + msg->err = ERR_OK; + TCPIP_NETIFAPI_ACK(msg); +} + /** * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the * tcpip_thread context. @@ -103,6 +117,28 @@ netifapi_netif_add(struct netif *netif, return msg.msg.err; } +/** + * Call netif_set_addr() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see netif_set_addr() + */ +err_t +netifapi_netif_set_addr(struct netif *netif, + struct ip_addr *ipaddr, + struct ip_addr *netmask, + struct ip_addr *gw) +{ + struct netifapi_msg msg; + msg.function = do_netifapi_netif_set_addr; + msg.msg.netif = netif; + msg.msg.msg.add.ipaddr = ipaddr; + msg.msg.msg.add.netmask = netmask; + msg.msg.msg.add.gw = gw; + TCPIP_NETIFAPI(&msg); + return msg.msg.err; +} + /** * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe * way by running that function inside the tcpip_thread context. diff --git a/src/include/lwip/netifapi.h b/src/include/lwip/netifapi.h index 36c6bd0a..4145dd74 100644 --- a/src/include/lwip/netifapi.h +++ b/src/include/lwip/netifapi.h @@ -78,6 +78,11 @@ err_t netifapi_netif_add ( struct netif *netif, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif) ); +err_t netifapi_netif_set_addr ( struct netif *netif, + struct ip_addr *ipaddr, + struct ip_addr *netmask, + struct ip_addr *gw ); + err_t netifapi_netif_common ( struct netif *netif, void (* voidfunc)(struct netif *netif), err_t (* errtfunc)(struct netif *netif) );