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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [ethernet/] [lwIP_130/] [src/] [include/] [netif/] [etharp.h] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
/*
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
#include "lwip/opt.h"
39
 
40
#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
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 __cplusplus
48
extern "C" {
49
#endif
50
 
51
#ifndef ETH_PAD_SIZE
52
#define ETH_PAD_SIZE          0
53
#endif
54
 
55
#ifndef ETHARP_HWADDR_LEN
56
#define ETHARP_HWADDR_LEN     6
57
#endif
58
 
59
#ifdef PACK_STRUCT_USE_INCLUDES
60
#  include "arch/bpstruct.h"
61
#endif
62
PACK_STRUCT_BEGIN
63
#if (defined(__MWERKS__)  || defined(__CWCC__))
64
        #pragma options align= packed
65
#endif
66
struct eth_addr {
67
  PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
68
} PACK_STRUCT_STRUCT;
69
PACK_STRUCT_END
70
#ifdef PACK_STRUCT_USE_INCLUDES
71
#  include "arch/epstruct.h"
72
#endif
73
 
74
#ifdef PACK_STRUCT_USE_INCLUDES
75
#  include "arch/bpstruct.h"
76
#endif
77
PACK_STRUCT_BEGIN
78
#if (defined(__MWERKS__)  || defined(__CWCC__))
79
        #pragma options align= packed
80
#endif
81
struct eth_hdr {
82
#if ETH_PAD_SIZE
83
  PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
84
#endif
85
  PACK_STRUCT_FIELD(struct eth_addr dest);
86
  PACK_STRUCT_FIELD(struct eth_addr src);
87
  PACK_STRUCT_FIELD(u16_t type);
88
} PACK_STRUCT_STRUCT;
89
PACK_STRUCT_END
90
#ifdef PACK_STRUCT_USE_INCLUDES
91
#  include "arch/epstruct.h"
92
#endif
93
 
94
#ifdef PACK_STRUCT_USE_INCLUDES
95
#  include "arch/bpstruct.h"
96
#endif
97
PACK_STRUCT_BEGIN
98
#if (defined(__MWERKS__)  || defined(__CWCC__))
99
        #pragma options align= packed
100
#endif
101
/** the ARP message */
102
struct etharp_hdr {
103
  PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
104
  PACK_STRUCT_FIELD(u16_t hwtype);
105
  PACK_STRUCT_FIELD(u16_t proto);
106
  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
107
  PACK_STRUCT_FIELD(u16_t opcode);
108
  PACK_STRUCT_FIELD(struct eth_addr shwaddr);
109
  PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
110
  PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
111
  PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
112
} PACK_STRUCT_STRUCT;
113
PACK_STRUCT_END
114
#ifdef PACK_STRUCT_USE_INCLUDES
115
#  include "arch/epstruct.h"
116
#endif
117
 
118
#ifdef PACK_STRUCT_USE_INCLUDES
119
#  include "arch/bpstruct.h"
120
#endif
121
PACK_STRUCT_BEGIN
122
#if (defined(__MWERKS__)  || defined(__CWCC__))
123
        #pragma options align= packed
124
#endif
125
struct ethip_hdr {
126
  PACK_STRUCT_FIELD(struct eth_hdr eth);
127
  PACK_STRUCT_FIELD(struct ip_hdr ip);
128
} PACK_STRUCT_STRUCT;
129
PACK_STRUCT_END
130
#ifdef PACK_STRUCT_USE_INCLUDES
131
#  include "arch/epstruct.h"
132
#endif
133
 
134
/** 5 seconds period */
135
#define ARP_TMR_INTERVAL 5000
136
 
137
#define ETHTYPE_ARP       0x0806
138
#define ETHTYPE_IP        0x0800
139
#define ETHTYPE_PPPOEDISC 0x8863  /* PPP Over Ethernet Discovery Stage */
140
#define ETHTYPE_PPPOE     0x8864  /* PPP Over Ethernet Session Stage */
141
 
142
/** ARP message types (opcodes) */
143
#define ARP_REQUEST 1
144
#define ARP_REPLY   2
145
 
146
#if ARP_QUEUEING
147
/** struct for queueing outgoing packets for unknown address
148
  * defined here to be accessed by memp.h
149
  */
150
struct etharp_q_entry {
151
  struct etharp_q_entry *next;
152
  struct pbuf *p;
153
};
154
#endif /* ARP_QUEUEING */
155
 
156
#define etharp_init() /* Compatibility define, not init needed. */
157
void etharp_tmr(void);
158
s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
159
         struct eth_addr **eth_ret, struct ip_addr **ip_ret);
160
void etharp_ip_input(struct netif *netif, struct pbuf *p);
161
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
162
         struct pbuf *p);
163
err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
164
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
165
err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
166
 
167
err_t ethernet_input(struct pbuf *p, struct netif *netif);
168
 
169
#if LWIP_AUTOIP
170
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
171
                 const struct eth_addr *ethdst_addr,
172
                 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
173
                 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
174
                 const u16_t opcode);
175
#endif /* LWIP_AUTOIP */
176
 
177
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
178
 
179
extern const struct eth_addr ethbroadcast, ethzero;
180
 
181
#ifdef __cplusplus
182
}
183
#endif
184
 
185
#endif /* LWIP_ARP */
186
 
187
#endif /* __NETIF_ARP_H__ */

powered by: WebSVN 2.1.0

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