3 * Network Interface Sequential API module
\r
8 * Redistribution and use in source and binary forms, with or without modification,
\r
9 * are permitted provided that the following conditions are met:
\r
11 * 1. Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the following disclaimer.
\r
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
14 * this list of conditions and the following disclaimer in the documentation
\r
15 * and/or other materials provided with the distribution.
\r
16 * 3. The name of the author may not be used to endorse or promote products
\r
17 * derived from this software without specific prior written permission.
\r
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
\r
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
\r
22 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
\r
24 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\r
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
\r
30 * This file is part of the lwIP TCP/IP stack.
\r
34 #include "lwip/opt.h"
\r
36 #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
\r
38 #include "lwip/netifapi.h"
\r
39 #include "lwip/tcpip.h"
\r
42 * Call netif_add() inside the tcpip_thread context.
\r
45 do_netifapi_netif_add( struct netifapi_msg_msg *msg)
\r
47 if (!netif_add( msg->netif,
\r
48 msg->msg.add.ipaddr,
\r
49 msg->msg.add.netmask,
\r
53 msg->msg.add.input)) {
\r
58 TCPIP_NETIFAPI_ACK(msg);
\r
62 * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
\r
63 * tcpip_thread context.
\r
66 do_netifapi_netif_common( struct netifapi_msg_msg *msg)
\r
68 if (msg->msg.common.errtfunc!=NULL) {
\r
70 msg->msg.common.errtfunc(msg->netif);
\r
73 msg->msg.common.voidfunc(msg->netif);
\r
75 TCPIP_NETIFAPI_ACK(msg);
\r
79 * Call netif_add() in a thread-safe way by running that function inside the
\r
80 * tcpip_thread context.
\r
82 * @note for params @see netif_add()
\r
85 netifapi_netif_add(struct netif *netif,
\r
86 struct ip_addr *ipaddr,
\r
87 struct ip_addr *netmask,
\r
90 err_t (* init)(struct netif *netif),
\r
91 err_t (* input)(struct pbuf *p, struct netif *netif))
\r
93 struct netifapi_msg msg;
\r
94 msg.function = do_netifapi_netif_add;
\r
95 msg.msg.netif = netif;
\r
96 msg.msg.msg.add.ipaddr = ipaddr;
\r
97 msg.msg.msg.add.netmask = netmask;
\r
98 msg.msg.msg.add.gw = gw;
\r
99 msg.msg.msg.add.state = state;
\r
100 msg.msg.msg.add.init = init;
\r
101 msg.msg.msg.add.input = input;
\r
102 TCPIP_NETIFAPI(&msg);
\r
103 return msg.msg.err;
\r
107 * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
\r
108 * way by running that function inside the tcpip_thread context.
\r
110 * @note use only for functions where there is only "netif" parameter.
\r
113 netifapi_netif_common( struct netif *netif,
\r
114 void (* voidfunc)(struct netif *netif),
\r
115 err_t (* errtfunc)(struct netif *netif) )
\r
117 struct netifapi_msg msg;
\r
118 msg.function = do_netifapi_netif_common;
\r
119 msg.msg.netif = netif;
\r
120 msg.msg.msg.common.voidfunc = voidfunc;
\r
121 msg.msg.msg.common.errtfunc = errtfunc;
\r
122 TCPIP_NETIFAPI(&msg);
\r
123 return msg.msg.err;
\r
126 #endif /* LWIP_NETIF_API */
\r