]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/lwip_tcpip/v2_0/include/netif/etharp.h
Initial revision
[karo-tx-redboot.git] / packages / net / lwip_tcpip / v2_0 / include / netif / etharp.h
1 /*
2  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3  * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
4  * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
5  * All rights reserved. 
6  * 
7  * Redistribution and use in source and binary forms, with or without modification, 
8  * are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission. 
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
19  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
21  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
23  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
26  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
27  * OF SUCH DAMAGE.
28  *
29  * This file is part of the lwIP TCP/IP stack.
30  * 
31  * Author: Adam Dunkels <adam@sics.se>
32  *
33  */
34
35 #ifndef __NETIF_ETHARP_H__
36 #define __NETIF_ETHARP_H__
37
38 #ifndef PAD_ETH_SIZE
39 #define PAD_ETH_SIZE 0
40 #endif
41
42 #include "lwip/pbuf.h"
43 #include "lwip/ip_addr.h"
44 #include "lwip/netif.h"
45 #include "lwip/ip.h"
46
47 #ifdef PACK_STRUCT_USE_INCLUDES
48 #  include "arch/bpstruct.h"
49 #endif
50 PACK_STRUCT_BEGIN
51 struct eth_addr {
52   PACK_STRUCT_FIELD(u8_t addr[6]);
53 } PACK_STRUCT_STRUCT;
54 PACK_STRUCT_END
55
56 PACK_STRUCT_BEGIN
57 struct eth_hdr {
58 #if PAD_ETH_SIZE
59   PACK_STRUCT_FIELD(u8_t padding[PAD_ETH_SIZE]);
60 #endif
61   PACK_STRUCT_FIELD(struct eth_addr dest);
62   PACK_STRUCT_FIELD(struct eth_addr src);
63   PACK_STRUCT_FIELD(u16_t type);
64 } PACK_STRUCT_STRUCT;
65 PACK_STRUCT_END
66
67 PACK_STRUCT_BEGIN
68 /** the ARP message */
69 struct etharp_hdr {
70   PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
71   PACK_STRUCT_FIELD(u16_t hwtype);
72   PACK_STRUCT_FIELD(u16_t proto);
73   PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
74   PACK_STRUCT_FIELD(u16_t opcode);
75   PACK_STRUCT_FIELD(struct eth_addr shwaddr);
76   PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
77   PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
78   PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
79 } PACK_STRUCT_STRUCT;
80 PACK_STRUCT_END
81
82 PACK_STRUCT_BEGIN
83 struct ethip_hdr {
84   PACK_STRUCT_FIELD(struct eth_hdr eth);
85   PACK_STRUCT_FIELD(struct ip_hdr ip);
86 };
87 #ifdef PACK_STRUCT_USE_INCLUDES
88 #  include "arch/epstruct.h"
89 #endif
90
91 #define ARP_TMR_INTERVAL 10000
92
93 #define ETHTYPE_ARP 0x0806
94 #define ETHTYPE_IP  0x0800
95
96 void etharp_init(void);
97 void etharp_tmr(void);
98 struct pbuf *etharp_ip_input(struct netif *netif, struct pbuf *p);
99 struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
100          struct pbuf *p);
101 struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr,
102          struct pbuf *q);
103 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
104
105
106
107 #endif /* __NETIF_ARP_H__ */