UbixOS V2 2.0

netifapi.h
Go to the documentation of this file.
1
6 /*
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27 * OF SUCH DAMAGE.
28 *
29 * This file is part of the lwIP TCP/IP stack.
30 *
31 */
32 #ifndef LWIP_HDR_NETIFAPI_H
33 #define LWIP_HDR_NETIFAPI_H
34
35 #include "net/opt.h"
36
37 #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
38
39 #include "net/sys.h"
40 #include "net/netif.h"
41 #include "net/dhcp.h"
42 #include "net/autoip.h"
43 #include "net/priv/tcpip_priv.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #if LWIP_MPU_COMPATIBLE
50 #define NETIFAPI_IPADDR_DEF(type, m) type m
51 #else /* LWIP_MPU_COMPATIBLE */
52 #define NETIFAPI_IPADDR_DEF(type, m) const type * m
53 #endif /* LWIP_MPU_COMPATIBLE */
54
55 typedef void (*netifapi_void_fn)(struct netif *netif);
56 typedef err_t (*netifapi_errt_fn)(struct netif *netif);
57
58 struct netifapi_msg {
59 struct tcpip_api_call_data call;
60 struct netif *netif;
61 union {
62 struct {
63 #if LWIP_IPV4
64 NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr);
65 NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask);
66 NETIFAPI_IPADDR_DEF(ip4_addr_t, gw);
67 #endif /* LWIP_IPV4 */
68 void *state;
69 netif_init_fn init;
70 netif_input_fn input;
71 } add;
72 struct {
73 netifapi_void_fn voidfunc;
74 netifapi_errt_fn errtfunc;
75 } common;
76 } msg;
77 };
78
79
80 /* API for application */
81 err_t netifapi_netif_add(struct netif *netif,
82 #if LWIP_IPV4
83 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
84 #endif /* LWIP_IPV4 */
85 void *state, netif_init_fn init, netif_input_fn input);
86
87 #if LWIP_IPV4
88 err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
89 const ip4_addr_t *netmask, const ip4_addr_t *gw);
90 #endif /* LWIP_IPV4*/
91
92 err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
93 netifapi_errt_fn errtfunc);
94
96 #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
97
98 #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
99
100 #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
101
102 #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
103
104 #define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
105
106 #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
107
114 #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
115
116 #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
117
118 #define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL)
119
120 #define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew)
121
122 #define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release)
123
130 #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
131
132 #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
133
134 #ifdef __cplusplus
135 }
136 #endif
137
138 #endif /* LWIP_NETIF_API */
139
140 #endif /* LWIP_HDR_NETIFAPI_H */
tcpip_priv.h
sys.h
opt.h
tcpip_api_call_data
Definition: tcpip_priv.h:97
autoip.h
netif_input_fn
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition: netif.h:170
netif.h
netif
Definition: netif.h:233
dhcp.h
err_t
s8_t err_t
Definition: err.h:57
netif_init_fn
err_t(* netif_init_fn)(struct netif *netif)
Definition: netif.h:163
LWIP_IPV4
#define LWIP_IPV4
Definition: lwipopts.h:109