www.pudn.com > TCPmodbushy.rar > netif.h


/* 
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 
 * All rights reserved.  
 *  
 * Redistribution and use in source and binary forms, with or without modification,  
 * are permitted provided that the following conditions are met: 
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer. 
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution. 
 * 3. The name of the author may not be used to endorse or promote products 
 *    derived from this software without specific prior written permission.  
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED  
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF  
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT  
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN  
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING  
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY  
 * OF SUCH DAMAGE. 
 * 
 * This file is part of the lwIP TCP/IP stack. 
 *  
 * Author: Adam Dunkels  
 * 
 */ 
#ifndef __LWIP_NETIF_H__ 
#define __LWIP_NETIF_H__ 
 
#include "o:/lwip/opt.h" 
 
#include "o:/lwip/err.h" 
 
#include "o:/IPV4/lwip/ip_addr.h" 
 
#include "o:/IPV4/lwip/inet.h" 
#include "o:/lwip/pbuf.h" 
#if LWIP_DHCP 
#  include "o:/lwip/dhcp.h" 
#endif 
 
/** must be the maximum of all used hardware address lengths 
    across all types of interfaces in use */ 
#define NETIF_MAX_HWADDR_LEN 6U 
 
/** TODO: define the use (where, when, whom) of netif flags */ 
 
/** whether the network interface is 'up'. this is 
 * a software flag used to control whether this network 
 * interface is enabled and processes traffic. 
 */ 
#define NETIF_FLAG_UP 0x1U 
/** if set, the netif has broadcast capability */ 
#define NETIF_FLAG_BROADCAST 0x2U 
/** if set, the netif is one end of a point-to-point connection */ 
#define NETIF_FLAG_POINTTOPOINT 0x4U 
/** if set, the interface is configured using DHCP */ 
#define NETIF_FLAG_DHCP 0x08U 
/** if set, the interface has an active link 
 *  (set by the network interface driver) */ 
#define NETIF_FLAG_LINK_UP 0x10U 
 
#define MAC_HWADDRESS_LEN	6 
 
/** Generic data structure used for all lwIP network interfaces. 
 *  The following fields should be filled in by the initialization 
 *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ 
 
struct netif { 
  /** pointer to next in linked list */ 
//  struct netif *next; 
 
  /** IP address configuration in network byte order */ 
  struct ip_addr ip_addr; 
  struct ip_addr netmask; 
  struct ip_addr gw; 
 
  /** This function is called by the network device driver 
   *  to pass a packet up the TCP/IP stack. */ 
//  err_t (* input)(struct pbuf xdata *p, struct netif xdata *inp); 
  /** This function is called by the IP module when it wants 
   *  to send a packet on the interface. This function typically 
   *  first resolves the hardware address, then sends the packet. */ 
//  err_t (* output)(struct netif xdata *netif, struct pbuf xdata *p, 
//       struct ip_addr *ipaddr); 
  /** This function is called by the ARP module when it wants 
   *  to send a packet on the interface. This function outputs 
   *  the pbuf as-is on the link medium. */ 
//  err_t (* linkoutput)(struct netif xdata *netif, struct pbuf xdata *p); 
  /** This field can be set by the device driver and could point 
   *  to state information for the device. */ 
  void  xdata *state; 
#if LWIP_DHCP 
  /** the DHCP client state information for this netif */ 
  struct dhcp xdata *dhcp; 
#endif 
  /** number of bytes used in hwaddr */ 
//  u8_t hwaddr_len; 
  /** link level hardware address of this interface */ 
  u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; 
  /** maximum transfer unit (in bytes) */ 
//  u16_t mtu; 
  /** flags (see NETIF_FLAG_ above) */ 
  u8_t flags; 
  /** link type */ 
  u8_t link_type; 
  /** descriptive abbreviation */ 
//  char name[2]; 
  /** number of this interface */ 
//  u8_t num; 
}; 
 
extern struct netif xdata *netif; 
 
void netif_Init( void ); 
//void netif_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw); 
void netif_set_ipaddr(struct ip_addr xdata *ipaddr); 
void netif_set_netmask(struct ip_addr xdata *netmast); 
void netif_set_gw(struct ip_addr xdata *gw); 
void netif_set_up(void); 
void netif_set_down(void); 
u8_t netif_is_up(void); 
 
#endif /* __LWIP_NETIF_H__ */