Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

netif.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2003 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 #include "lwip/err.h"
00038 
00039 #include "lwip/ip_addr.h"
00040 
00041 #include "lwip/inet.h"
00042 #include "lwip/pbuf.h"
00043 #include "lwip/dhcp.h"
00044 
00047 #define NETIF_MAX_HWADDR_LEN 6
00048 
00052 #define NETIF_FLAG_UP 1U
00053 
00054 #define NETIF_FLAG_BROADCAST 2U
00055 
00056 #define NETIF_FLAG_POINTTOPOINT 4U
00057 
00058 #define NETIF_FLAG_DHCP 8U
00059 
00061 struct netif {
00063   struct netif *next;
00068   struct ip_addr ip_addr;
00069   struct ip_addr netmask;
00070   struct ip_addr gw;
00071 
00074   err_t (* input)(struct pbuf *p, struct netif *inp);
00078   err_t (* output)(struct netif *netif, struct pbuf *p,
00079                    struct ip_addr *ipaddr);
00083   err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
00086   void *state;
00087 #if LWIP_DHCP
00088 
00089   struct dhcp *dhcp;
00090 #endif
00091 
00092   unsigned char hwaddr_len;
00094   unsigned char hwaddr[NETIF_MAX_HWADDR_LEN];
00096   u16_t mtu;
00098   char name[2];
00100   u8_t num;
00102   u8_t flags;
00103 };
00104 
00106 extern struct netif *netif_list;
00108 extern struct netif *netif_default;
00109 
00110 /* netif_init() must be called first. */
00111 void netif_init(void);
00112 
00113 struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
00114                         struct ip_addr *gw,
00115                         void *state,
00116                         err_t (* init)(struct netif *netif),
00117                         err_t (* input)(struct pbuf *p, struct netif *netif));
00118 
00119 void
00120 netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
00121           struct ip_addr *gw);
00122 void netif_remove(struct netif * netif);
00123 
00124 /* Returns a network interface given its name. The name is of the form
00125    "et0", where the first two letters are the "name" field in the
00126    netif structure, and the digit is in the num field in the same
00127    structure. */
00128 struct netif *netif_find(char *name);
00129 
00130 void netif_set_default(struct netif *netif);
00131 
00132 void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
00133 void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
00134 void netif_set_gw(struct netif *netif, struct ip_addr *gw);
00135 
00136 #endif /* __LWIP_NETIF_H__ */

Generated on Wed Jan 14 12:58:56 2004 for RTL-lwIP-0.4 by doxygen 1.3.4