[457] | 1 | /**
|
---|
| 2 | * @file
|
---|
| 3 | * netif API (to be used from non-TCPIP threads)
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 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 "lwip/opt.h"
|
---|
| 36 |
|
---|
| 37 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
---|
| 38 |
|
---|
| 39 | #include "lwip/sys.h"
|
---|
| 40 | #include "lwip/netif.h"
|
---|
| 41 | #include "lwip/dhcp.h"
|
---|
| 42 | #include "lwip/autoip.h"
|
---|
| 43 | #include "lwip/priv/tcpip_priv.h"
|
---|
| 44 | #include "lwip/priv/api_msg.h"
|
---|
| 45 | #include "lwip/prot/ethernet.h"
|
---|
| 46 |
|
---|
| 47 | #ifdef __cplusplus
|
---|
| 48 | extern "C" {
|
---|
| 49 | #endif
|
---|
| 50 |
|
---|
| 51 | /* API for application */
|
---|
| 52 | #if LWIP_ARP && LWIP_IPV4
|
---|
| 53 | /* Used for netfiapi_arp_* APIs */
|
---|
| 54 | enum netifapi_arp_entry {
|
---|
| 55 | NETIFAPI_ARP_PERM /* Permanent entry */
|
---|
| 56 | /* Other entry types can be added here */
|
---|
| 57 | };
|
---|
| 58 |
|
---|
| 59 | /** @ingroup netifapi_arp */
|
---|
| 60 | err_t netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifapi_arp_entry type);
|
---|
| 61 | /** @ingroup netifapi_arp */
|
---|
| 62 | err_t netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type);
|
---|
| 63 | #endif /* LWIP_ARP && LWIP_IPV4 */
|
---|
| 64 |
|
---|
| 65 | err_t netifapi_netif_add(struct netif *netif,
|
---|
| 66 | #if LWIP_IPV4
|
---|
| 67 | const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
---|
| 68 | #endif /* LWIP_IPV4 */
|
---|
| 69 | void *state, netif_init_fn init, netif_input_fn input);
|
---|
| 70 |
|
---|
| 71 | #if LWIP_IPV4
|
---|
| 72 | err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
---|
| 73 | const ip4_addr_t *netmask, const ip4_addr_t *gw);
|
---|
| 74 | #endif /* LWIP_IPV4*/
|
---|
| 75 |
|
---|
| 76 | err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
|
---|
| 77 | netifapi_errt_fn errtfunc);
|
---|
| 78 |
|
---|
| 79 | /** @ingroup netifapi_netif */
|
---|
| 80 | err_t netifapi_netif_name_to_index(const char *name, u8_t *index);
|
---|
| 81 | /** @ingroup netifapi_netif */
|
---|
| 82 | err_t netifapi_netif_index_to_name(u8_t index, char *name);
|
---|
| 83 |
|
---|
| 84 | /** @ingroup netifapi_netif
|
---|
| 85 | * @see netif_remove()
|
---|
| 86 | */
|
---|
| 87 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
|
---|
| 88 | /** @ingroup netifapi_netif
|
---|
| 89 | * @see netif_set_up()
|
---|
| 90 | */
|
---|
| 91 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
|
---|
| 92 | /** @ingroup netifapi_netif
|
---|
| 93 | * @see netif_set_down()
|
---|
| 94 | */
|
---|
| 95 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
|
---|
| 96 | /** @ingroup netifapi_netif
|
---|
| 97 | * @see netif_set_default()
|
---|
| 98 | */
|
---|
| 99 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
|
---|
| 100 | /** @ingroup netifapi_netif
|
---|
| 101 | * @see netif_set_link_up()
|
---|
| 102 | */
|
---|
| 103 | #define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
|
---|
| 104 | /** @ingroup netifapi_netif
|
---|
| 105 | * @see netif_set_link_down()
|
---|
| 106 | */
|
---|
| 107 | #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
|
---|
| 108 |
|
---|
| 109 | /**
|
---|
| 110 | * @defgroup netifapi_dhcp4 DHCPv4
|
---|
| 111 | * @ingroup netifapi
|
---|
| 112 | * To be called from non-TCPIP threads
|
---|
| 113 | */
|
---|
| 114 | /** @ingroup netifapi_dhcp4
|
---|
| 115 | * @see dhcp_start()
|
---|
| 116 | */
|
---|
| 117 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
|
---|
| 118 | /**
|
---|
| 119 | * @ingroup netifapi_dhcp4
|
---|
| 120 | * @deprecated Use netifapi_dhcp_release_and_stop() instead.
|
---|
| 121 | */
|
---|
| 122 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
|
---|
| 123 | /** @ingroup netifapi_dhcp4
|
---|
| 124 | * @see dhcp_inform()
|
---|
| 125 | */
|
---|
| 126 | #define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL)
|
---|
| 127 | /** @ingroup netifapi_dhcp4
|
---|
| 128 | * @see dhcp_renew()
|
---|
| 129 | */
|
---|
| 130 | #define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew)
|
---|
| 131 | /**
|
---|
| 132 | * @ingroup netifapi_dhcp4
|
---|
| 133 | * @deprecated Use netifapi_dhcp_release_and_stop() instead.
|
---|
| 134 | */
|
---|
| 135 | #define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release)
|
---|
| 136 | /** @ingroup netifapi_dhcp4
|
---|
| 137 | * @see dhcp_release_and_stop()
|
---|
| 138 | */
|
---|
| 139 | #define netifapi_dhcp_release_and_stop(n) netifapi_netif_common(n, dhcp_release_and_stop, NULL)
|
---|
| 140 |
|
---|
| 141 | /**
|
---|
| 142 | * @defgroup netifapi_autoip AUTOIP
|
---|
| 143 | * @ingroup netifapi
|
---|
| 144 | * To be called from non-TCPIP threads
|
---|
| 145 | */
|
---|
| 146 | /** @ingroup netifapi_autoip
|
---|
| 147 | * @see autoip_start()
|
---|
| 148 | */
|
---|
| 149 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
|
---|
| 150 | /** @ingroup netifapi_autoip
|
---|
| 151 | * @see autoip_stop()
|
---|
| 152 | */
|
---|
| 153 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
|
---|
| 154 |
|
---|
| 155 | #ifdef __cplusplus
|
---|
| 156 | }
|
---|
| 157 | #endif
|
---|
| 158 |
|
---|
| 159 | #endif /* LWIP_NETIF_API */
|
---|
| 160 |
|
---|
| 161 | #endif /* LWIP_HDR_NETIFAPI_H */
|
---|