Rev 3991 | Rev 4307 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3991 | Rev 4243 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Lukas Mejdrech |
2 | * Copyright (c) 2009 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup arp |
29 | /** @addtogroup arp |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * ARP module. |
34 | * ARP module. |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_ARP_H__ |
37 | #ifndef __NET_ARP_H__ |
38 | #define __NET_ARP_H__ |
38 | #define __NET_ARP_H__ |
39 | 39 | ||
40 | #include <rwlock.h> |
40 | #include <rwlock.h> |
41 | 41 | ||
42 | #include <ipc/ipc.h> |
42 | #include <ipc/ipc.h> |
43 | 43 | ||
44 | #include "../../netif/device.h" |
44 | #include "../../include/device.h" |
45 | 45 | ||
46 | #include "../../structures/generic_char_map.h" |
46 | #include "../../structures/generic_char_map.h" |
47 | #include "../../structures/int_map.h" |
47 | #include "../../structures/int_map.h" |
48 | #include "../../structures/measured_strings.h" |
48 | #include "../../structures/measured_strings.h" |
49 | 49 | ||
50 | 50 | ||
51 | /** Type definition of the ARP global data. |
51 | /** Type definition of the ARP global data. |
52 | * @see arp_globals |
52 | * @see arp_globals |
53 | */ |
53 | */ |
54 | typedef struct arp_globals arp_globals_t; |
54 | typedef struct arp_globals arp_globals_t; |
55 | 55 | ||
56 | /** Type definition of the ARP device specific data. |
56 | /** Type definition of the ARP device specific data. |
57 | * @see arp_device |
57 | * @see arp_device |
58 | */ |
58 | */ |
59 | typedef struct arp_device arp_device_t; |
59 | typedef struct arp_device arp_device_t; |
60 | 60 | ||
61 | /** Type definition of the ARP device specific data pointer. |
61 | /** Type definition of the ARP device specific data pointer. |
62 | * @see arp_device |
62 | * @see arp_device |
63 | */ |
63 | */ |
64 | typedef arp_device_t * arp_device_ref; |
64 | typedef arp_device_t * arp_device_ref; |
65 | 65 | ||
66 | /** Type definition of the ARP protocol specific data. |
66 | /** Type definition of the ARP protocol specific data. |
67 | * @see arp_proto |
67 | * @see arp_proto |
68 | */ |
68 | */ |
69 | typedef struct arp_proto arp_proto_t; |
69 | typedef struct arp_proto arp_proto_t; |
70 | 70 | ||
71 | /** Type definition of the ARP protocol specific data pointer. |
71 | /** Type definition of the ARP protocol specific data pointer. |
72 | * @see arp_proto |
72 | * @see arp_proto |
73 | */ |
73 | */ |
74 | typedef arp_proto_t * arp_proto_ref; |
74 | typedef arp_proto_t * arp_proto_ref; |
75 | 75 | ||
76 | /** ARP address cache. |
76 | /** ARP address cache. |
77 | * Maps devices to the ARP device specific data. |
77 | * Maps devices to the ARP device specific data. |
78 | * @see device.h |
78 | * @see device.h |
79 | */ |
79 | */ |
80 | DEVICE_MAP_DECLARE( arp_cache, arp_device_t ) |
80 | DEVICE_MAP_DECLARE( arp_cache, arp_device_t ) |
81 | 81 | ||
82 | /** ARP protocol map. |
82 | /** ARP protocol map. |
83 | * Maps protocol identifiers to the ARP protocol specific data. |
83 | * Maps protocol identifiers to the ARP protocol specific data. |
84 | * @see int_map.h |
84 | * @see int_map.h |
85 | */ |
85 | */ |
86 | INT_MAP_DECLARE( arp_protos, arp_proto_t ) |
86 | INT_MAP_DECLARE( arp_protos, arp_proto_t ) |
87 | 87 | ||
88 | /** ARP address map. |
88 | /** ARP address map. |
89 | * Translates addresses. |
89 | * Translates addresses. |
90 | * @see generic_char_map.h |
90 | * @see generic_char_map.h |
91 | */ |
91 | */ |
92 | GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t ) |
92 | GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t ) |
93 | 93 | ||
94 | /** ARP device specific data. |
94 | /** ARP device specific data. |
95 | */ |
95 | */ |
96 | struct arp_device{ |
96 | struct arp_device{ |
97 | /** Device identifier. |
97 | /** Device identifier. |
98 | */ |
98 | */ |
99 | device_id_t device_id; |
99 | device_id_t device_id; |
100 | /** Hardware type. |
100 | /** Hardware type. |
101 | */ |
101 | */ |
102 | ipcarg_t hardware; |
102 | ipcarg_t hardware; |
103 | /** Reserved packet prefix length. |
103 | /** Reserved packet prefix length. |
104 | */ |
104 | */ |
105 | ipcarg_t prefix; |
105 | ipcarg_t prefix; |
106 | /** Maximal packet content length. |
106 | /** Maximal packet content length. |
107 | */ |
107 | */ |
108 | ipcarg_t content; |
108 | ipcarg_t content; |
109 | /** Reserved packet suffix length. |
109 | /** Reserved packet suffix length. |
110 | */ |
110 | */ |
111 | ipcarg_t suffix; |
111 | ipcarg_t suffix; |
112 | /** Packet address length. |
112 | /** Packet address length. |
113 | * The hardware address length is used. |
113 | * The hardware address length is used. |
114 | */ |
114 | */ |
115 | ipcarg_t addr_len; |
115 | ipcarg_t addr_len; |
116 | /** Actual device hardware address. |
116 | /** Actual device hardware address. |
117 | */ |
117 | */ |
118 | measured_string_ref addr; |
118 | measured_string_ref addr; |
119 | /** Actual device hardware address data. |
119 | /** Actual device hardware address data. |
120 | */ |
120 | */ |
121 | char * addr_data; |
121 | char * addr_data; |
122 | /** Broadcast device hardware address. |
122 | /** Broadcast device hardware address. |
123 | */ |
123 | */ |
124 | measured_string_ref broadcast_addr; |
124 | measured_string_ref broadcast_addr; |
125 | /** Broadcast device hardware address data. |
125 | /** Broadcast device hardware address data. |
126 | */ |
126 | */ |
127 | char * broadcast_data; |
127 | char * broadcast_data; |
128 | /** Device driver service. |
128 | /** Device driver service. |
129 | */ |
129 | */ |
130 | services_t service; |
130 | services_t service; |
131 | /** Driver phone. |
131 | /** Driver phone. |
132 | */ |
132 | */ |
133 | int phone; |
133 | int phone; |
134 | /** Protocol map. |
134 | /** Protocol map. |
135 | * Address map for each protocol. |
135 | * Address map for each protocol. |
136 | */ |
136 | */ |
137 | arp_protos_t protos; |
137 | arp_protos_t protos; |
138 | }; |
138 | }; |
139 | 139 | ||
140 | /** ARP protocol specific data. |
140 | /** ARP protocol specific data. |
141 | */ |
141 | */ |
142 | struct arp_proto{ |
142 | struct arp_proto{ |
143 | /** Protocol service. |
143 | /** Protocol service. |
144 | */ |
144 | */ |
145 | services_t service; |
145 | services_t service; |
146 | /** Actual device protocol address. |
146 | /** Actual device protocol address. |
147 | */ |
147 | */ |
148 | measured_string_ref addr; |
148 | measured_string_ref addr; |
149 | /** Actual device protocol address data. |
149 | /** Actual device protocol address data. |
150 | */ |
150 | */ |
151 | char * addr_data; |
151 | char * addr_data; |
152 | /** Address map. |
152 | /** Address map. |
153 | */ |
153 | */ |
154 | arp_addr_t addresses; |
154 | arp_addr_t addresses; |
155 | }; |
155 | }; |
156 | 156 | ||
157 | /** ARP global data. |
157 | /** ARP global data. |
158 | */ |
158 | */ |
159 | struct arp_globals{ |
159 | struct arp_globals{ |
160 | /** Networking module phone. |
160 | /** Networking module phone. |
161 | */ |
161 | */ |
162 | int networking_phone; |
162 | int networking_phone; |
163 | /** Safety lock. |
163 | /** Safety lock. |
164 | */ |
164 | */ |
165 | rwlock_t lock; |
165 | rwlock_t lock; |
166 | /** ARP address cache. |
166 | /** ARP address cache. |
167 | */ |
167 | */ |
168 | arp_cache_t cache; |
168 | arp_cache_t cache; |
169 | }; |
169 | }; |
170 | 170 | ||
171 | #endif |
171 | #endif |
172 | 172 | ||
173 | /** @} |
173 | /** @} |
174 | */ |
174 | */ |
175 | 175 |