SMB - attribute offset fixed, filetimes all fully working
[libogc.git] / libdb / uIP / uip_arp.h
blob16569cf43ab99fb049a2f9a85cd7b6f6f257c677
1 /**
2 * \addtogroup uip
3 * @{
4 */
6 /**
7 * \addtogroup uiparp
8 * @{
9 */
11 /**
12 * \file
13 * Macros and definitions for the ARP module.
14 * \author Adam Dunkels <adam@dunkels.com>
19 * Copyright (c) 2001-2003, Adam Dunkels.
20 * All rights reserved.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. The name of the author may not be used to endorse or promote
31 * products derived from this software without specific prior
32 * written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
35 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
38 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 * This file is part of the uIP TCP/IP stack.
51 #ifndef __UIP_ARP_H__
52 #define __UIP_ARP_H__
54 #include "uip.h"
55 #include "uip_arch.h"
57 #define UIP_ARP_TMRINTERVAL 5000
59 #define UIP_ETHTYPE_ARP 0x0806
60 #define UIP_ETHTYPE_IP 0x0800
61 #define UIP_ETHTYPE_IP6 0x86dd
62 /**
63 * Representation of a 48-bit Ethernet address.
65 PACK_STRUCT_BEGIN
66 struct uip_eth_addr {
67 PACK_STRUCT_FIELD(u8_t addr[6]);
68 } PACK_STRUCT_STRUCT;
69 PACK_STRUCT_END
71 /**
72 * The Ethernet header.
74 PACK_STRUCT_BEGIN
75 struct uip_eth_hdr {
76 PACK_STRUCT_FIELD(struct uip_eth_addr dest);
77 PACK_STRUCT_FIELD(struct uip_eth_addr src);
78 PACK_STRUCT_FIELD(u16_t type);
79 } PACK_STRUCT_STRUCT;
80 PACK_STRUCT_END
82 PACK_STRUCT_BEGIN
83 struct uip_arp_hdr {
84 PACK_STRUCT_FIELD(struct uip_eth_hdr ethhdr);
85 PACK_STRUCT_FIELD(u16_t hwtype);
86 PACK_STRUCT_FIELD(u16_t protocol);
87 PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
88 PACK_STRUCT_FIELD(u16_t opcode);
89 PACK_STRUCT_FIELD(struct uip_eth_addr shwaddr);
90 PACK_STRUCT_FIELD(struct uip_ip_addr2 sipaddr);
91 PACK_STRUCT_FIELD(struct uip_eth_addr dhwaddr);
92 PACK_STRUCT_FIELD(struct uip_ip_addr2 dipaddr);
93 } PACK_STRUCT_STRUCT;
94 PACK_STRUCT_END
96 PACK_STRUCT_BEGIN
97 struct uip_ethip_hdr {
98 PACK_STRUCT_FIELD(struct uip_eth_hdr ethhdr);
99 PACK_STRUCT_FIELD(struct uip_ip_hdr ip);
100 } PACK_STRUCT_STRUCT;
101 PACK_STRUCT_END
104 extern struct uip_eth_addr uip_ethaddr;
106 struct uip_pbuf;
107 struct uip_netif;
109 /* The uip_arp_init() function must be called before any of the other
110 ARP functions. */
111 void uip_arp_init(void);
113 /* The uip_arp_ipin() function should be called whenever an IP packet
114 arrives from the Ethernet. This function refreshes the ARP table or
115 inserts a new mapping if none exists. The function assumes that an
116 IP packet with an Ethernet header is present in the uip_buf buffer
117 and that the length of the packet is in the uip_len variable. */
118 void uip_arp_ipin(struct uip_netif *netif,struct uip_pbuf *p);
120 /* The uip_arp_arpin() should be called when an ARP packet is received
121 by the Ethernet driver. This function also assumes that the
122 Ethernet frame is present in the uip_buf buffer. When the
123 uip_arp_arpin() function returns, the contents of the uip_buf
124 buffer should be sent out on the Ethernet if the uip_len variable
125 is > 0. */
126 void uip_arp_arpin(struct uip_netif *netif,struct uip_eth_addr *ethaddr,struct uip_pbuf *p);
128 /* The uip_arp_out() function should be called when an IP packet
129 should be sent out on the Ethernet. This function creates an
130 Ethernet header before the IP header in the uip_buf buffer. The
131 Ethernet header will have the correct Ethernet MAC destination
132 address filled in if an ARP table entry for the destination IP
133 address (or the IP address of the default router) is present. If no
134 such table entry is found, the IP packet is overwritten with an ARP
135 request and we rely on TCP to retransmit the packet that was
136 overwritten. In any case, the uip_len variable holds the length of
137 the Ethernet frame that should be transmitted. */
138 s8_t uip_arp_out(struct uip_netif *netif,struct uip_ip_addr *ipaddr,struct uip_pbuf *q);
140 /* The uip_arp_timer() function should be called every ten seconds. It
141 is responsible for flushing old entries in the ARP table. */
142 void uip_arp_timer(void);
144 s8_t uip_arp_arpquery(struct uip_netif *netif,struct uip_ip_addr *ipaddr,struct uip_pbuf *q);
146 s8_t uip_arp_arprequest(struct uip_netif *netif,struct uip_ip_addr *ipaddr);
148 #endif /* __UIP_ARP_H__ */