OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [uIP_Demo_Rowley_ARM7/] [uip/] [uip_arp.h] - Blame information for rev 754

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/**
2
 * \addtogroup uip
3
 * @{
4
 */
5
 
6
/**
7
 * \addtogroup uiparp
8
 * @{
9
 */
10
 
11
/**
12
 * \file
13
 * Macros and definitions for the ARP module.
14
 * \author Adam Dunkels <adam@dunkels.com>
15
 */
16
 
17
 
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
 * $Id: uip_arp.h 2 2011-07-17 20:13:17Z filepang@gmail.com $
49
 *
50
 */
51
 
52
#ifndef __UIP_ARP_H__
53
#define __UIP_ARP_H__
54
 
55
#include "uip.h"
56
 
57
 
58
/**
59
 * Representation of a 48-bit Ethernet address.
60
 */
61
struct uip_eth_addr {
62
  u8_t addr[6];
63
} __attribute__ ((packed, aligned (1)));
64
 
65
extern struct uip_eth_addr uip_ethaddr;
66
 
67
/**
68
 * The Ethernet header.
69
 */
70
struct uip_eth_hdr {
71
  struct uip_eth_addr dest;
72
  struct uip_eth_addr src;
73
  u16_t type;
74
} __attribute__ ((packed));
75
 
76
#define UIP_ETHTYPE_ARP 0x0806
77
#define UIP_ETHTYPE_IP  0x0800
78
#define UIP_ETHTYPE_IP6 0x86dd 
79
 
80
 
81
/* The uip_arp_init() function must be called before any of the other
82
   ARP functions. */
83
void uip_arp_init(void);
84
 
85
/* The uip_arp_ipin() function should be called whenever an IP packet
86
   arrives from the Ethernet. This function refreshes the ARP table or
87
   inserts a new mapping if none exists. The function assumes that an
88
   IP packet with an Ethernet header is present in the uip_buf buffer
89
   and that the length of the packet is in the uip_len variable. */
90
void uip_arp_ipin(void);
91
 
92
/* The uip_arp_arpin() should be called when an ARP packet is received
93
   by the Ethernet driver. This function also assumes that the
94
   Ethernet frame is present in the uip_buf buffer. When the
95
   uip_arp_arpin() function returns, the contents of the uip_buf
96
   buffer should be sent out on the Ethernet if the uip_len variable
97
   is > 0. */
98
void uip_arp_arpin(void);
99
 
100
/* The uip_arp_out() function should be called when an IP packet
101
   should be sent out on the Ethernet. This function creates an
102
   Ethernet header before the IP header in the uip_buf buffer. The
103
   Ethernet header will have the correct Ethernet MAC destination
104
   address filled in if an ARP table entry for the destination IP
105
   address (or the IP address of the default router) is present. If no
106
   such table entry is found, the IP packet is overwritten with an ARP
107
   request and we rely on TCP to retransmit the packet that was
108
   overwritten. In any case, the uip_len variable holds the length of
109
   the Ethernet frame that should be transmitted. */
110
void uip_arp_out(void);
111
 
112
/* The uip_arp_timer() function should be called every ten seconds. It
113
   is responsible for flushing old entries in the ARP table. */
114
void uip_arp_timer(void);
115
 
116
/** @} */
117
 
118
/**
119
 * \addtogroup uipconffunc
120
 * @{
121
 */
122
 
123
/**
124
 * Set the default router's IP address.
125
 *
126
 * \param addr A pointer to a 4-byte array containing the IP address
127
 * of the default router.
128
 *
129
 * \hideinitializer
130
 */
131
#define uip_setdraddr(addr) do { uip_arp_draddr[0] = addr[0]; \
132
                                 uip_arp_draddr[1] = addr[1]; } while(0)
133
 
134
/**
135
 * Set the netmask.
136
 *
137
 * \param addr A pointer to a 4-byte array containing the IP address
138
 * of the netmask.
139
 *
140
 * \hideinitializer
141
 */
142
#define uip_setnetmask(addr) do { uip_arp_netmask[0] = addr[0]; \
143
                                  uip_arp_netmask[1] = addr[1]; } while(0)
144
 
145
 
146
/**
147
 * Get the default router's IP address.
148
 *
149
 * \param addr A pointer to a 4-byte array that will be filled in with
150
 * the IP address of the default router.
151
 *
152
 * \hideinitializer
153
 */
154
#define uip_getdraddr(addr) do { addr[0] = uip_arp_draddr[0]; \
155
                                 addr[1] = uip_arp_draddr[1]; } while(0)
156
 
157
/**
158
 * Get the netmask.
159
 *
160
 * \param addr A pointer to a 4-byte array that will be filled in with
161
 * the value of the netmask.
162
 *
163
 * \hideinitializer
164
 */
165
#define uip_getnetmask(addr) do { addr[0] = uip_arp_netmask[0]; \
166
                                  addr[1] = uip_arp_netmask[1]; } while(0)
167
 
168
 
169
/**
170
 * Specifiy the Ethernet MAC address.
171
 *
172
 * The ARP code needs to know the MAC address of the Ethernet card in
173
 * order to be able to respond to ARP queries and to generate working
174
 * Ethernet headers.
175
 *
176
 * \note This macro only specifies the Ethernet MAC address to the ARP
177
 * code. It cannot be used to change the MAC address of the Ethernet
178
 * card.
179
 *
180
 * \param eaddr A pointer to a struct uip_eth_addr containing the
181
 * Ethernet MAC address of the Ethernet card.
182
 *
183
 * \hideinitializer
184
 */
185
#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
186
                              uip_ethaddr.addr[1] = eaddr.addr[1];\
187
                              uip_ethaddr.addr[2] = eaddr.addr[2];\
188
                              uip_ethaddr.addr[3] = eaddr.addr[3];\
189
                              uip_ethaddr.addr[4] = eaddr.addr[4];\
190
                              uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
191
 
192
/** @} */
193
 
194
/**
195
 * \internal Internal variables that are set using the macros
196
 * uip_setdraddr and uip_setnetmask.
197
 */
198
extern u16_t uip_arp_draddr[2], uip_arp_netmask[2];
199
#endif /* __UIP_ARP_H__ */
200
 
201
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.