~marcus-mc/+junk/ps3sdk

« back to all changes in this revision

Viewing changes to src/lwip/src/include/netif/etharp.h

  • Committer: Marcus Comstedt
  • Date: 2009-08-02 16:05:58 UTC
  • Revision ID: marcus@mc.pp.se-20090802160558-zazx8adsuo9s4gqp
Imported LWIP stuff from emoon's sources.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
#include "lwip/pbuf.h"
 
40
#include "lwip/ip_addr.h"
 
41
#include "lwip/netif.h"
 
42
#include "lwip/ip.h"
 
43
 
 
44
#ifdef __cplusplus
 
45
extern "C" {
 
46
#endif
 
47
 
 
48
#ifndef ETH_PAD_SIZE
 
49
#define ETH_PAD_SIZE          0
 
50
#endif
 
51
 
 
52
#ifndef ETHARP_HWADDR_LEN
 
53
#define ETHARP_HWADDR_LEN     6
 
54
#endif
 
55
 
 
56
#ifdef PACK_STRUCT_USE_INCLUDES
 
57
#  include "arch/bpstruct.h"
 
58
#endif
 
59
PACK_STRUCT_BEGIN
 
60
struct eth_addr {
 
61
  PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
 
62
} PACK_STRUCT_STRUCT;
 
63
PACK_STRUCT_END
 
64
#ifdef PACK_STRUCT_USE_INCLUDES
 
65
#  include "arch/epstruct.h"
 
66
#endif
 
67
 
 
68
#ifdef PACK_STRUCT_USE_INCLUDES
 
69
#  include "arch/bpstruct.h"
 
70
#endif
 
71
PACK_STRUCT_BEGIN
 
72
struct eth_hdr {
 
73
#if ETH_PAD_SIZE
 
74
  PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
 
75
#endif
 
76
  PACK_STRUCT_FIELD(struct eth_addr dest);
 
77
  PACK_STRUCT_FIELD(struct eth_addr src);
 
78
  PACK_STRUCT_FIELD(u16_t type);
 
79
} PACK_STRUCT_STRUCT;
 
80
PACK_STRUCT_END
 
81
#ifdef PACK_STRUCT_USE_INCLUDES
 
82
#  include "arch/epstruct.h"
 
83
#endif
 
84
 
 
85
#ifdef PACK_STRUCT_USE_INCLUDES
 
86
#  include "arch/bpstruct.h"
 
87
#endif
 
88
PACK_STRUCT_BEGIN
 
89
/** the ARP message */
 
90
struct etharp_hdr {
 
91
  PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
 
92
  PACK_STRUCT_FIELD(u16_t hwtype);
 
93
  PACK_STRUCT_FIELD(u16_t proto);
 
94
  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
 
95
  PACK_STRUCT_FIELD(u16_t opcode);
 
96
  PACK_STRUCT_FIELD(struct eth_addr shwaddr);
 
97
  PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
 
98
  PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
 
99
  PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
 
100
} PACK_STRUCT_STRUCT;
 
101
PACK_STRUCT_END
 
102
#ifdef PACK_STRUCT_USE_INCLUDES
 
103
#  include "arch/epstruct.h"
 
104
#endif
 
105
 
 
106
#ifdef PACK_STRUCT_USE_INCLUDES
 
107
#  include "arch/bpstruct.h"
 
108
#endif
 
109
PACK_STRUCT_BEGIN
 
110
struct ethip_hdr {
 
111
  PACK_STRUCT_FIELD(struct eth_hdr eth);
 
112
  PACK_STRUCT_FIELD(struct ip_hdr ip);
 
113
} PACK_STRUCT_STRUCT;
 
114
PACK_STRUCT_END
 
115
#ifdef PACK_STRUCT_USE_INCLUDES
 
116
#  include "arch/epstruct.h"
 
117
#endif
 
118
 
 
119
/** 5 seconds period */
 
120
#define ARP_TMR_INTERVAL 5000
 
121
 
 
122
#define ETHTYPE_ARP 0x0806
 
123
#define ETHTYPE_IP  0x0800
 
124
 
 
125
/** ARP message types (opcodes) */
 
126
#define ARP_REQUEST 1
 
127
#define ARP_REPLY   2
 
128
 
 
129
#if ARP_QUEUEING
 
130
/** struct for queueing outgoing packets for unknown address
 
131
  * defined here to be accessed by memp.h
 
132
  */
 
133
struct etharp_q_entry {
 
134
  struct etharp_q_entry *next;
 
135
  struct pbuf *p;
 
136
};
 
137
#endif
 
138
 
 
139
void etharp_init(void);
 
140
void etharp_tmr(void);
 
141
s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
 
142
         struct eth_addr **eth_ret, struct ip_addr **ip_ret);
 
143
void etharp_ip_input(struct netif *netif, struct pbuf *p);
 
144
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
 
145
         struct pbuf *p);
 
146
err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
 
147
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
 
148
err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
 
149
 
 
150
#if LWIP_AUTOIP
 
151
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
 
152
                 const struct eth_addr *ethdst_addr,
 
153
                 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
 
154
                 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
 
155
                 const u16_t opcode);
 
156
#endif /* LWIP_AUTOIP */
 
157
 
 
158
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
 
159
 
 
160
/* finally, check some defines */
 
161
#if ARP_TABLE_SIZE > 0x7f
 
162
#error ARP_TABLE_SIZE must fit in an s8_t
 
163
#endif
 
164
 
 
165
#ifdef __cplusplus
 
166
}
 
167
#endif
 
168
 
 
169
#endif /* __NETIF_ARP_H__ */