ID the MBED processor on the network if you have more than one. View MBED name on DHCP of your Router - Example \"MBED PE\" Change your ID in Core / host.h
netif.h
00001 /* 00002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 #ifndef __LWIP_NETIF_H__ 00033 #define __LWIP_NETIF_H__ 00034 00035 #include "lwip/opt.h" 00036 00037 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 00038 00039 #include "lwip/err.h" 00040 00041 #include "lwip/ip_addr.h" 00042 00043 #include "lwip/def.h" 00044 #include "lwip/pbuf.h" 00045 #if LWIP_DHCP 00046 struct dhcp; 00047 #endif 00048 #if LWIP_AUTOIP 00049 struct autoip; 00050 #endif 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 /* Throughout this file, IP addresses are expected to be in 00057 * the same byte order as in IP_PCB. */ 00058 00059 /* must be the maximum of all used hardware address lengths 00060 across all types of interfaces in use */ 00061 #define NETIF_MAX_HWADDR_LEN 6U 00062 00063 /* Whether the network interface is 'up'. This is 00064 * a software flag used to control whether this network 00065 * interface is enabled and processes traffic. 00066 * It is set by the startup code (for static IP configuration) or 00067 * by dhcp/autoip when an address has been assigned. 00068 */ 00069 #define NETIF_FLAG_UP 0x01U 00070 /* If set, the netif has broadcast capability. 00071 * Set by the netif driver in its init function. */ 00072 #define NETIF_FLAG_BROADCAST 0x02U 00073 /* If set, the netif is one end of a point-to-point connection. 00074 * Set by the netif driver in its init function. */ 00075 #define NETIF_FLAG_POINTTOPOINT 0x04U 00076 /* If set, the interface is configured using DHCP. 00077 * Set by the DHCP code when starting or stopping DHCP. */ 00078 #define NETIF_FLAG_DHCP 0x08U 00079 /* If set, the interface has an active link 00080 * (set by the network interface driver). 00081 * Either set by the netif driver in its init function (if the link 00082 * is up at that time) or at a later point once the link comes up 00083 * (if link detection is supported by the hardware). */ 00084 #define NETIF_FLAG_LINK_UP 0x10U 00085 /* If set, the netif is an ethernet device using ARP. 00086 * Set by the netif driver in its init function. 00087 * Used to check input packet types and use of DHCP. */ 00088 #define NETIF_FLAG_ETHARP 0x20U 00089 /* If set, the netif is an ethernet device. It might not use 00090 * ARP or TCP/IP if it is used for PPPoE only. 00091 */ 00092 #define NETIF_FLAG_ETHERNET 0x40U 00093 /* If set, the netif has IGMP capability. 00094 * Set by the netif driver in its init function. */ 00095 #define NETIF_FLAG_IGMP 0x80U 00096 00097 /* Function prototype for netif init functions. Set up flags and output/linkoutput 00098 * callback functions in this function. 00099 * 00100 * @param netif The netif to initialize 00101 */ 00102 typedef err_t (*netif_init_fn)(struct netif *netif); 00103 /* Function prototype for netif->input functions. This function is saved as 'input' 00104 * callback function in the netif struct. Call it when a packet has been received. 00105 * 00106 * @param p The received packet, copied into a pbuf 00107 * @param inp The netif which received the packet 00108 */ 00109 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); 00110 /* Function prototype for netif->output functions. Called by lwIP when a packet 00111 * shall be sent. For ethernet netif, set this to 'etharp_output' and set 00112 * 'linkoutput'. 00113 * 00114 * @param netif The netif which shall send a packet 00115 * @param p The packet to send (p->payload points to IP header) 00116 * @param ipaddr The IP address to which the packet shall be sent 00117 */ 00118 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, 00119 ip_addr_t *ipaddr); 00120 /* Function prototype for netif->linkoutput functions. Only used for ethernet 00121 * netifs. This function is called by ARP when a packet shall be sent. 00122 * 00123 * @param netif The netif which shall send a packet 00124 * @param p The packet to send (raw ethernet packet) 00125 */ 00126 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); 00127 /* Function prototype for netif status- or link-callback functions. */ 00128 typedef void (*netif_status_callback_fn)(struct netif *netif); 00129 /* Function prototype for netif igmp_mac_filter functions */ 00130 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, 00131 ip_addr_t *group, u8_t action); 00132 00133 /* Generic data structure used for all lwIP network interfaces. 00134 * The following fields should be filled in by the initialization 00135 * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ 00136 struct netif { 00137 /* pointer to next in linked list */ 00138 struct netif *next; 00139 00140 /* IP address configuration in network byte order */ 00141 ip_addr_t ip_addr; 00142 ip_addr_t netmask; 00143 ip_addr_t gw; 00144 00145 /* This function is called by the network device driver 00146 * to pass a packet up the TCP/IP stack. */ 00147 netif_input_fn input; 00148 /* This function is called by the IP module when it wants 00149 * to send a packet on the interface. This function typically 00150 * first resolves the hardware address, then sends the packet. */ 00151 netif_output_fn output; 00152 /* This function is called by the ARP module when it wants 00153 * to send a packet on the interface. This function outputs 00154 * the pbuf as-is on the link medium. */ 00155 netif_linkoutput_fn linkoutput; 00156 #if LWIP_NETIF_STATUS_CALLBACK 00157 /* This function is called when the netif state is set to up or down 00158 */ 00159 netif_status_callback_fn status_callback; 00160 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 00161 #if LWIP_NETIF_LINK_CALLBACK 00162 /* This function is called when the netif link is set to up or down 00163 */ 00164 netif_status_callback_fn link_callback; 00165 #endif /* LWIP_NETIF_LINK_CALLBACK */ 00166 /* This field can be set by the device driver and could point 00167 * to state information for the device. */ 00168 void *state; 00169 #if LWIP_DHCP 00170 /* the DHCP client state information for this netif */ 00171 struct dhcp *dhcp; 00172 #endif /* LWIP_DHCP */ 00173 #if LWIP_AUTOIP 00174 /* the AutoIP client state information for this netif */ 00175 struct autoip *autoip; 00176 #endif 00177 #if LWIP_NETIF_HOSTNAME 00178 /* the hostname for this netif, NULL is a valid value */ 00179 char* hostname; 00180 #endif /* LWIP_NETIF_HOSTNAME */ 00181 /* maximum transfer unit (in bytes) */ 00182 u16_t mtu; 00183 /* number of bytes used in hwaddr */ 00184 u8_t hwaddr_len; 00185 /* link level hardware address of this interface */ 00186 u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; 00187 /* flags (see NETIF_FLAG_ above) */ 00188 u8_t flags; 00189 /* descriptive abbreviation */ 00190 char name[2]; 00191 /* number of this interface */ 00192 u8_t num; 00193 #if LWIP_SNMP 00194 /* link type (from "snmp_ifType" enum from snmp.h) */ 00195 u8_t link_type; 00196 /* (estimate) link speed */ 00197 u32_t link_speed; 00198 /* timestamp at last change made (up/down) */ 00199 u32_t ts; 00200 /* counters */ 00201 u32_t ifinoctets; 00202 u32_t ifinucastpkts; 00203 u32_t ifinnucastpkts; 00204 u32_t ifindiscards; 00205 u32_t ifoutoctets; 00206 u32_t ifoutucastpkts; 00207 u32_t ifoutnucastpkts; 00208 u32_t ifoutdiscards; 00209 #endif /* LWIP_SNMP */ 00210 #if LWIP_IGMP 00211 /* This function could be called to add or delete a entry in the multicast 00212 filter table of the ethernet MAC.*/ 00213 netif_igmp_mac_filter_fn igmp_mac_filter; 00214 #endif /* LWIP_IGMP */ 00215 #if LWIP_NETIF_HWADDRHINT 00216 u8_t *addr_hint; 00217 #endif /* LWIP_NETIF_HWADDRHINT */ 00218 #if ENABLE_LOOPBACK 00219 /* List of packets to be queued for ourselves. */ 00220 struct pbuf *loop_first; 00221 struct pbuf *loop_last; 00222 #if LWIP_LOOPBACK_MAX_PBUFS 00223 u16_t loop_cnt_current; 00224 #endif /* LWIP_LOOPBACK_MAX_PBUFS */ 00225 #endif /* ENABLE_LOOPBACK */ 00226 }; 00227 00228 #if LWIP_SNMP 00229 #define NETIF_INIT_SNMP(netif, type, speed) \ 00230 /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ 00231 (netif)->link_type = (type); \ 00232 /* your link speed here (units: bits per second) */ \ 00233 (netif)->link_speed = (speed); \ 00234 (netif)->ts = 0; \ 00235 (netif)->ifinoctets = 0; \ 00236 (netif)->ifinucastpkts = 0; \ 00237 (netif)->ifinnucastpkts = 0; \ 00238 (netif)->ifindiscards = 0; \ 00239 (netif)->ifoutoctets = 0; \ 00240 (netif)->ifoutucastpkts = 0; \ 00241 (netif)->ifoutnucastpkts = 0; \ 00242 (netif)->ifoutdiscards = 0 00243 #else /* LWIP_SNMP */ 00244 #define NETIF_INIT_SNMP(netif, type, speed) 00245 #endif /* LWIP_SNMP */ 00246 00247 00248 /* The list of network interfaces. */ 00249 extern struct netif *netif_list; 00250 /* The default network interface. */ 00251 extern struct netif *netif_default; 00252 00253 void netif_init(void); 00254 00255 struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, 00256 ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input); 00257 00258 void 00259 netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, 00260 ip_addr_t *gw); 00261 void netif_remove(struct netif * netif); 00262 00263 /* Returns a network interface given its name. The name is of the form 00264 "et0", where the first two letters are the "name" field in the 00265 netif structure, and the digit is in the num field in the same 00266 structure. */ 00267 struct netif *netif_find(char *name); 00268 00269 void netif_set_default(struct netif *netif); 00270 00271 void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr); 00272 void netif_set_netmask(struct netif *netif, ip_addr_t *netmask); 00273 void netif_set_gw(struct netif *netif, ip_addr_t *gw); 00274 00275 void netif_set_up(struct netif *netif); 00276 void netif_set_down(struct netif *netif); 00277 /* Ask if an interface is up */ 00278 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) 00279 00280 #if LWIP_NETIF_STATUS_CALLBACK 00281 void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); 00282 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 00283 00284 void netif_set_link_up(struct netif *netif); 00285 void netif_set_link_down(struct netif *netif); 00286 /* Ask if a link is up */ 00287 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) 00288 00289 #if LWIP_NETIF_LINK_CALLBACK 00290 void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); 00291 #endif /* LWIP_NETIF_LINK_CALLBACK */ 00292 00293 #if LWIP_NETIF_HOSTNAME 00294 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) 00295 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) 00296 #endif /* LWIP_NETIF_HOSTNAME */ 00297 00298 #if LWIP_IGMP 00299 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) 00300 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) 00301 #endif /* LWIP_IGMP */ 00302 00303 #if ENABLE_LOOPBACK 00304 err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); 00305 void netif_poll(struct netif *netif); 00306 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING 00307 void netif_poll_all(void); 00308 #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 00309 #endif /* ENABLE_LOOPBACK */ 00310 00311 #ifdef __cplusplus 00312 } 00313 #endif 00314 00315 #endif /* __LWIP_NETIF_H__ */
Generated on Tue Jul 12 2022 20:22:58 by 1.7.2