Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers netifapi.h Source File

netifapi.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * netif API (to be used from non-TCPIP threads)
00004  */
00005 
00006 /*
00007  * Redistribution and use in source and binary forms, with or without modification,
00008  * are permitted provided that the following conditions are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright notice,
00011  *    this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright notice,
00013  *    this list of conditions and the following disclaimer in the documentation
00014  *    and/or other materials provided with the distribution.
00015  * 3. The name of the author may not be used to endorse or promote products
00016  *    derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00019  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00020  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00021  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00022  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00023  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00026  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00027  * OF SUCH DAMAGE.
00028  *
00029  * This file is part of the lwIP TCP/IP stack.
00030  *
00031  */
00032 #ifndef LWIP_HDR_NETIFAPI_H
00033 #define LWIP_HDR_NETIFAPI_H
00034 
00035 #include "lwip/opt.h"
00036 
00037 #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
00038 
00039 #include "lwip/sys.h"
00040 #include "lwip/netif.h"
00041 #include "lwip/dhcp.h"
00042 #include "lwip/autoip.h"
00043 #include "lwip/priv/tcpip_priv.h"
00044 #include "lwip/priv/api_msg.h"
00045 #include "lwip/prot/ethernet.h"
00046 
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050 
00051 /* API for application */
00052 #if LWIP_ARP && LWIP_IPV4
00053 /* Used for netfiapi_arp_* APIs */
00054 enum netifapi_arp_entry {
00055   NETIFAPI_ARP_PERM /* Permanent entry */
00056   /* Other entry types can be added here */
00057 };
00058 
00059 /** @ingroup netifapi_arp */
00060 err_t netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifapi_arp_entry type);
00061 /** @ingroup netifapi_arp */
00062 err_t netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type);
00063 #endif /* LWIP_ARP && LWIP_IPV4 */
00064 
00065 err_t netifapi_netif_add(struct netif *netif,
00066 #if LWIP_IPV4
00067                          const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
00068 #endif /* LWIP_IPV4 */
00069                          void *state, netif_init_fn init, netif_input_fn input);
00070 
00071 #if LWIP_IPV4
00072 err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
00073                               const ip4_addr_t *netmask, const ip4_addr_t *gw);
00074 #endif /* LWIP_IPV4*/
00075 
00076 err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
00077                             netifapi_errt_fn errtfunc);
00078 
00079 /** @ingroup netifapi_netif */
00080 err_t netifapi_netif_name_to_index(const char *name, u8_t *index);
00081 /** @ingroup netifapi_netif */
00082 err_t netifapi_netif_index_to_name(u8_t index, char *name);
00083 
00084 /** @ingroup netifapi_netif
00085   * @see netif_remove()
00086   */
00087 #define netifapi_netif_remove(n)        netifapi_netif_common(n, netif_remove, NULL)
00088 /** @ingroup netifapi_netif
00089   * @see netif_set_up()
00090   */
00091 #define netifapi_netif_set_up(n)        netifapi_netif_common(n, netif_set_up, NULL)
00092 /** @ingroup netifapi_netif
00093   * @see netif_set_down()
00094   */
00095 #define netifapi_netif_set_down(n)      netifapi_netif_common(n, netif_set_down, NULL)
00096 /** @ingroup netifapi_netif
00097   * @see netif_set_default()
00098   */
00099 #define netifapi_netif_set_default(n)   netifapi_netif_common(n, netif_set_default, NULL)
00100 /** @ingroup netifapi_netif
00101   * @see netif_set_link_up()
00102   */
00103 #define netifapi_netif_set_link_up(n)   netifapi_netif_common(n, netif_set_link_up, NULL)
00104 /** @ingroup netifapi_netif
00105   * @see netif_set_link_down()
00106   */
00107 #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
00108 
00109 /**
00110  * @defgroup netifapi_dhcp4 DHCPv4
00111  * @ingroup netifapi
00112  * To be called from non-TCPIP threads
00113  */
00114 /** @ingroup netifapi_dhcp4
00115   * @see dhcp_start()
00116   */
00117 #define netifapi_dhcp_start(n)            netifapi_netif_common(n, NULL, dhcp_start)
00118 /**
00119  * @ingroup netifapi_dhcp4
00120  * @deprecated Use netifapi_dhcp_release_and_stop() instead.
00121  */
00122 #define netifapi_dhcp_stop(n)             netifapi_netif_common(n, dhcp_stop, NULL)
00123 /** @ingroup netifapi_dhcp4
00124   * @see dhcp_inform()
00125   */
00126 #define netifapi_dhcp_inform(n)           netifapi_netif_common(n, dhcp_inform, NULL)
00127 /** @ingroup netifapi_dhcp4
00128   * @see dhcp_renew()
00129   */
00130 #define netifapi_dhcp_renew(n)            netifapi_netif_common(n, NULL, dhcp_renew)
00131 /**
00132  * @ingroup netifapi_dhcp4
00133  * @deprecated Use netifapi_dhcp_release_and_stop() instead.
00134  */
00135 #define netifapi_dhcp_release(n)          netifapi_netif_common(n, NULL, dhcp_release)
00136 /** @ingroup netifapi_dhcp4
00137   * @see dhcp_release_and_stop()
00138   */
00139 #define netifapi_dhcp_release_and_stop(n) netifapi_netif_common(n, dhcp_release_and_stop, NULL)
00140 
00141 /**
00142  * @defgroup netifapi_autoip AUTOIP
00143  * @ingroup netifapi
00144  * To be called from non-TCPIP threads
00145  */
00146 /** @ingroup netifapi_autoip
00147   * @see autoip_start()
00148   */
00149 #define netifapi_autoip_start(n)      netifapi_netif_common(n, NULL, autoip_start)
00150 /** @ingroup netifapi_autoip
00151   * @see autoip_stop()
00152   */
00153 #define netifapi_autoip_stop(n)       netifapi_netif_common(n, NULL, autoip_stop)
00154 
00155 #ifdef __cplusplus
00156 }
00157 #endif
00158 
00159 #endif /* LWIP_NETIF_API */
00160 
00161 #endif /* LWIP_HDR_NETIFAPI_H */