Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygennetif.h
Go to the documentation of this file.
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 00061 #define NETIF_MAX_HWADDR_LEN 6U 00062 00069 #define NETIF_FLAG_UP 0x01U 00070 00072 #define NETIF_FLAG_BROADCAST 0x02U 00073 00075 #define NETIF_FLAG_POINTTOPOINT 0x04U 00076 00078 #define NETIF_FLAG_DHCP 0x08U 00079 00084 #define NETIF_FLAG_LINK_UP 0x10U 00085 00088 #define NETIF_FLAG_ETHARP 0x20U 00089 00092 #define NETIF_FLAG_ETHERNET 0x40U 00093 00095 #define NETIF_FLAG_IGMP 0x80U 00096 00102 typedef err_t (*netif_init_fn)(struct netif *netif); 00109 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); 00118 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, 00119 ip_addr_t *ipaddr); 00126 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); 00128 typedef void (*netif_status_callback_fn)(struct netif *netif); 00130 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, 00131 ip_addr_t *group, u8_t action); 00132 00136 struct netif { 00138 struct netif *next; 00139 00141 ip_addr_t ip_addr; 00142 ip_addr_t netmask; 00143 ip_addr_t gw; 00144 00147 netif_input_fn input; 00151 netif_output_fn output; 00155 netif_linkoutput_fn linkoutput; 00156 #if LWIP_NETIF_STATUS_CALLBACK 00157 00159 netif_status_callback_fn status_callback; 00160 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 00161 #if LWIP_NETIF_LINK_CALLBACK 00162 00164 netif_status_callback_fn link_callback; 00165 #endif /* LWIP_NETIF_LINK_CALLBACK */ 00166 00168 void *state; 00169 #if LWIP_DHCP 00170 00171 struct dhcp *dhcp; 00172 #endif /* LWIP_DHCP */ 00173 #if LWIP_AUTOIP 00174 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 00182 u16_t mtu; 00184 u8_t hwaddr_len; 00186 u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; 00188 u8_t flags; 00190 char name[2]; 00192 u8_t num; 00193 #if LWIP_SNMP 00194 00195 u8_t link_type; 00197 u32_t link_speed; 00199 u32_t ts; 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 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 00249 extern struct netif *netif_list; 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); 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); 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 Sun May 27 2012 04:36:04 for ReactOS by
1.7.6.1
|