RetroArch
uip_arp.h
Go to the documentation of this file.
1 
18 /*
19  * Copyright (c) 2001-2003, Adam Dunkels.
20  * All rights reserved.
21  *
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.
33  *
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.
45  *
46  * This file is part of the uIP TCP/IP stack.
47  *
48  *
49  */
50 
51 #ifndef __UIP_ARP_H__
52 #define __UIP_ARP_H__
53 
54 #include "uip.h"
55 #include "uip_arch.h"
56 
57 #define UIP_ARP_TMRINTERVAL 5000
58 
59 #define UIP_ETHTYPE_ARP 0x0806
60 #define UIP_ETHTYPE_IP 0x0800
61 #define UIP_ETHTYPE_IP6 0x86dd
62 
66 struct uip_eth_addr {
70 
75 struct uip_eth_hdr {
76  PACK_STRUCT_FIELD(struct uip_eth_addr dest);
81 
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);
95 
97 struct uip_ethip_hdr {
98  PACK_STRUCT_FIELD(struct uip_eth_hdr ethhdr);
99  PACK_STRUCT_FIELD(struct uip_ip_hdr ip);
102 
103 
104 extern struct uip_eth_addr uip_ethaddr;
105 
106 struct uip_pbuf;
107 struct uip_netif;
108 
109 /* The uip_arp_init() function must be called before any of the other
110  ARP functions. */
111 void uip_arp_init(void);
112 
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);
119 
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);
127 
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);
139 
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);
143 
144 s8_t uip_arp_arpquery(struct uip_netif *netif,struct uip_ip_addr *ipaddr,struct uip_pbuf *q);
145 
146 s8_t uip_arp_arprequest(struct uip_netif *netif,struct uip_ip_addr *ipaddr);
147 
148 #endif /* __UIP_ARP_H__ */
149 
150 
Definition: uip_ip.h:82
PACK_STRUCT_END struct uip_eth_addr uip_ethaddr
s8 s8_t
Definition: cc.h:44
Definition: uip_arp.h:83
Definition: uip_ip.h:95
PACK_STRUCT_FIELD(u8_t addr[6])
#define PACK_STRUCT_BEGIN
Definition: arch.h:46
void uip_arp_arpin(struct uip_netif *netif, struct uip_eth_addr *ethaddr, struct uip_pbuf *p)
Definition: uip_arp.c:263
Definition: uip_pbuf.h:27
Definition: netif.h:72
PACK_STRUCT_FIELD(struct uip_eth_addr dest)
s8_t uip_arp_out(struct uip_netif *netif, struct uip_ip_addr *ipaddr, struct uip_pbuf *q)
Definition: uip_arp.c:346
void uip_arp_ipin(struct uip_netif *netif, struct uip_pbuf *p)
Definition: uip_arp.c:229
Definition: uip_arp.h:75
GLenum type
Definition: glext.h:6233
GLenum const GLvoid * addr
Definition: glext.h:10528
Definition: uip_arp.h:97
Definition: uip_arp.h:66
void uip_arp_init(void)
Definition: uip_arp.c:121
GLenum src
Definition: glext.h:6980
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:6414
s8_t uip_arp_arpquery(struct uip_netif *netif, struct uip_ip_addr *ipaddr, struct uip_pbuf *q)
Definition: uip_arp.c:390
GLfloat GLfloat p
Definition: glext.h:9809
#define PACK_STRUCT_END
Definition: arch.h:50
PACK_STRUCT_BEGIN struct uip_eth_addr PACK_STRUCT_STRUCT
u8 u8_t
Definition: cc.h:43
Definition: uip_ip.h:88
s8_t uip_arp_arprequest(struct uip_netif *netif, struct uip_ip_addr *ipaddr)
Definition: uip_arp.c:424
PACK_STRUCT_FIELD(struct uip_eth_hdr ethhdr)
void uip_arp_timer(void)
Definition: uip_arp.c:140
PACK_STRUCT_FIELD(struct uip_eth_hdr ethhdr)
Definition: uip_netif.h:29
u16 u16_t
Definition: cc.h:45