Contiki 3.x
uip_arp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2003, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote
14  * products derived from this software without specific prior
15  * written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * This file is part of the uIP TCP/IP stack.
30  *
31  *
32  */
33 
34 /**
35  * \file
36  * Macros and definitions for the ARP module.
37  * \author Adam Dunkels <adam@dunkels.com>
38  */
39 
40 /**
41  * \addtogroup uip
42  * @{
43  */
44 
45 /**
46  * \addtogroup uiparp
47  * @{
48  */
49 
50 #ifndef UIP_ARP_H_
51 #define UIP_ARP_H_
52 
53 #include "net/ip/uip.h"
54 
55 
56 
57 /**
58  * The Ethernet header.
59  */
60 struct uip_eth_hdr {
61  struct uip_eth_addr dest;
62  struct uip_eth_addr src;
63  uint16_t type;
64 };
65 
66 #define UIP_ETHTYPE_ARP 0x0806
67 #define UIP_ETHTYPE_IP 0x0800
68 #define UIP_ETHTYPE_IPV6 0x86dd
69 
70 
71 /* The uip_arp_init() function must be called before any of the other
72  ARP functions. */
73 void uip_arp_init(void);
74 
75 /* The uip_arp_ipin() function should be called whenever an IP packet
76  arrives from the Ethernet. This function refreshes the ARP table or
77  inserts a new mapping if none exists. The function assumes that an
78  IP packet with an Ethernet header is present in the uip_buf buffer
79  and that the length of the packet is in the uip_len variable. */
80 /*void uip_arp_ipin(void);*/
81 #define uip_arp_ipin()
82 
83 /* The uip_arp_arpin() should be called when an ARP packet is received
84  by the Ethernet driver. This function also assumes that the
85  Ethernet frame is present in the uip_buf buffer. When the
86  uip_arp_arpin() function returns, the contents of the uip_buf
87  buffer should be sent out on the Ethernet if the uip_len variable
88  is > 0. */
89 void uip_arp_arpin(void);
90 
91 /* The uip_arp_out() function should be called when an IP packet
92  should be sent out on the Ethernet. This function creates an
93  Ethernet header before the IP header in the uip_buf buffer. The
94  Ethernet header will have the correct Ethernet MAC destination
95  address filled in if an ARP table entry for the destination IP
96  address (or the IP address of the default router) is present. If no
97  such table entry is found, the IP packet is overwritten with an ARP
98  request and we rely on TCP to retransmit the packet that was
99  overwritten. In any case, the uip_len variable holds the length of
100  the Ethernet frame that should be transmitted. */
101 void uip_arp_out(void);
102 
103 /* The uip_arp_timer() function should be called every ten seconds. It
104  is responsible for flushing old entries in the ARP table. */
105 void uip_arp_timer(void);
106 
107 /** @} */
108 
109 /**
110  * \addtogroup uipconffunc
111  * @{
112  */
113 
114 
115 /**
116  * Specifiy the Ethernet MAC address.
117  *
118  * The ARP code needs to know the MAC address of the Ethernet card in
119  * order to be able to respond to ARP queries and to generate working
120  * Ethernet headers.
121  *
122  * \note This macro only specifies the Ethernet MAC address to the ARP
123  * code. It cannot be used to change the MAC address of the Ethernet
124  * card.
125  *
126  * \param eaddr A pointer to a struct uip_eth_addr containing the
127  * Ethernet MAC address of the Ethernet card.
128  *
129  * \hideinitializer
130  */
131 #define uip_setethaddr(eaddr) do {uip_lladdr.addr[0] = eaddr.addr[0]; \
132  uip_lladdr.addr[1] = eaddr.addr[1];\
133  uip_lladdr.addr[2] = eaddr.addr[2];\
134  uip_lladdr.addr[3] = eaddr.addr[3];\
135  uip_lladdr.addr[4] = eaddr.addr[4];\
136  uip_lladdr.addr[5] = eaddr.addr[5];} while(0)
137 
138 /** @} */
139 
140 
141 #endif /* UIP_ARP_H_ */
142 /** @} */
void uip_arp_out(void)
Prepend Ethernet header to an outbound IP packet and see if we need to send out an ARP request...
Definition: uip_arp.c:363
Header file for the uIP TCP/IP stack.
void uip_arp_timer(void)
Periodic ARP processing function.
Definition: uip_arp.c:147
void uip_arp_init(void)
Initialize the ARP module.
Definition: uip_arp.c:130
The Ethernet header.
Definition: uip_arp.h:60
802.3 address
Definition: uip.h:135
void uip_arp_arpin(void)
ARP processing for incoming IP packets.
Definition: uip_arp.c:283