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