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 00033 #ifndef __NETIF_ETHARP_H__ 00034 #define __NETIF_ETHARP_H__ 00035 00036 #include "lwip/pbuf.h" 00037 #include "lwip/ip_addr.h" 00038 #include "lwip/netif.h" 00039 #include "lwip/ip.h" 00040 00041 #ifdef PACK_STRUCT_USE_INCLUDES 00042 # include "arch/bpstruct.h" 00043 #endif 00044 PACK_STRUCT_BEGIN 00045 struct eth_addr { 00046 PACK_STRUCT_FIELD(u8_t addr[6]); 00047 } PACK_STRUCT_STRUCT; 00048 PACK_STRUCT_END 00049 00050 PACK_STRUCT_BEGIN 00051 struct eth_hdr { 00052 PACK_STRUCT_FIELD(struct eth_addr dest); 00053 PACK_STRUCT_FIELD(struct eth_addr src); 00054 PACK_STRUCT_FIELD(u16_t type); 00055 } PACK_STRUCT_STRUCT; 00056 PACK_STRUCT_END 00057 00058 PACK_STRUCT_BEGIN 00060 struct etharp_hdr { 00061 PACK_STRUCT_FIELD(struct eth_hdr ethhdr); 00062 PACK_STRUCT_FIELD(u16_t hwtype); 00063 PACK_STRUCT_FIELD(u16_t proto); 00064 PACK_STRUCT_FIELD(u16_t _hwlen_protolen); 00065 PACK_STRUCT_FIELD(u16_t opcode); 00066 PACK_STRUCT_FIELD(struct eth_addr shwaddr); 00067 PACK_STRUCT_FIELD(struct ip_addr sipaddr); 00068 PACK_STRUCT_FIELD(struct eth_addr dhwaddr); 00069 PACK_STRUCT_FIELD(struct ip_addr dipaddr); 00070 } PACK_STRUCT_STRUCT; 00071 PACK_STRUCT_END 00072 00073 PACK_STRUCT_BEGIN 00074 struct ethip_hdr { 00075 PACK_STRUCT_FIELD(struct eth_hdr eth); 00076 PACK_STRUCT_FIELD(struct ip_hdr ip); 00077 }; 00078 #ifdef PACK_STRUCT_USE_INCLUDES 00079 # include "arch/epstruct.h" 00080 #endif 00081 00082 #define ARP_TMR_INTERVAL 10000 00083 00084 #define ETHTYPE_ARP 0x0806 00085 #define ETHTYPE_IP 0x0800 00086 00087 void etharp_init(void); 00088 void etharp_tmr(void); 00089 struct pbuf *etharp_ip_input(struct netif *netif, struct pbuf *p); 00090 struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, 00091 struct pbuf *p); 00092 struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr, 00093 struct pbuf *q); 00094 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q); 00095 00096 00097 00098 #endif /* __NETIF_ARP_H__ */