Rev 4695 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4695 | Rev 4704 | ||
---|---|---|---|
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 ip |
29 | /** @addtogroup ip |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** @file |
34 | * @file |
34 | * IP module. |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_IP_H__ |
37 | #ifndef __NET_IP_H__ |
38 | #define __NET_IP_H__ |
38 | #define __NET_IP_H__ |
39 | 39 | ||
40 | #include <fibril_sync.h> |
40 | #include <fibril_sync.h> |
41 | 41 | ||
42 | #include <ipc/ipc.h> |
42 | #include <ipc/ipc.h> |
43 | #include <ipc/services.h> |
43 | #include <ipc/services.h> |
44 | 44 | ||
45 | #include "../../include/device.h" |
45 | #include "../../include/device.h" |
46 | #include "../../include/inet.h" |
46 | #include "../../include/inet.h" |
47 | #include "../../include/ip_interface.h" |
47 | #include "../../include/ip_interface.h" |
48 | 48 | ||
49 | #include "../../structures/int_map.h" |
49 | #include "../../structures/int_map.h" |
50 | #include "../../structures/generic_field.h" |
50 | #include "../../structures/generic_field.h" |
51 | #include "../../structures/module_map.h" |
51 | #include "../../structures/module_map.h" |
52 | 52 | ||
- | 53 | /** Type definition of the IP global data. |
|
- | 54 | * @see ip_globals |
|
- | 55 | */ |
|
- | 56 | typedef struct ip_globals ip_globals_t; |
|
- | 57 | ||
- | 58 | /** Type definition of the IP network interface specific data. |
|
- | 59 | * @see ip_netif |
|
- | 60 | */ |
|
53 | typedef struct ip_netif ip_netif_t; |
61 | typedef struct ip_netif ip_netif_t; |
- | 62 | ||
- | 63 | /** Type definition of the IP network interface specific data pointer. |
|
- | 64 | * @see ip_netif |
|
- | 65 | */ |
|
54 | typedef ip_netif_t * ip_netif_ref; |
66 | typedef ip_netif_t * ip_netif_ref; |
55 | 67 | ||
- | 68 | /** Type definition of the IP protocol specific data. |
|
- | 69 | * @see ip_proto |
|
- | 70 | */ |
|
56 | typedef struct ip_proto ip_proto_t; |
71 | typedef struct ip_proto ip_proto_t; |
- | 72 | ||
- | 73 | /** Type definition of the IP protocol specific data pointer. |
|
- | 74 | * @see ip_proto |
|
- | 75 | */ |
|
57 | typedef ip_proto_t * ip_proto_ref; |
76 | typedef ip_proto_t * ip_proto_ref; |
58 | 77 | ||
- | 78 | /** Type definition of the IP route specific data. |
|
- | 79 | * @see ip_route |
|
- | 80 | */ |
|
59 | typedef struct ip_route ip_route_t; |
81 | typedef struct ip_route ip_route_t; |
60 | typedef ip_route_t * ip_route_ref; |
- | |
61 | 82 | ||
- | 83 | /** Type definition of the IP route specific data pointer. |
|
- | 84 | * @see ip_route |
|
- | 85 | */ |
|
62 | typedef struct ip_globals ip_globals_t; |
86 | typedef ip_route_t * ip_route_ref; |
63 | 87 | ||
- | 88 | /** IP network interfaces. |
|
- | 89 | * Maps devices to the IP network interface specific data. |
|
- | 90 | * @see device.h |
|
- | 91 | */ |
|
64 | DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t ) |
92 | DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t ) |
65 | 93 | ||
- | 94 | /** IP registered protocols. |
|
- | 95 | * Maps protocols to the IP protocol specific data. |
|
- | 96 | * @see int_map.h |
|
- | 97 | */ |
|
66 | INT_MAP_DECLARE( ip_protos, ip_proto_t ) |
98 | INT_MAP_DECLARE( ip_protos, ip_proto_t ) |
67 | 99 | ||
- | 100 | /** IP routing table. |
|
- | 101 | * @see generic_field.h |
|
- | 102 | */ |
|
68 | GENERIC_FIELD_DECLARE( ip_routes, ip_route_t ) |
103 | GENERIC_FIELD_DECLARE( ip_routes, ip_route_t ) |
69 | 104 | ||
- | 105 | /** IP network interface specific data. |
|
- | 106 | */ |
|
70 | struct ip_netif{ |
107 | struct ip_netif{ |
- | 108 | /** Device identifier. |
|
- | 109 | */ |
|
71 | device_id_t device_id; |
110 | device_id_t device_id; |
- | 111 | /** Netif module service. |
|
- | 112 | */ |
|
72 | services_t service; |
113 | services_t service; |
- | 114 | /** Netif module phone. |
|
- | 115 | */ |
|
73 | int phone; |
116 | int phone; |
- | 117 | /** ARP module. |
|
- | 118 | * Assigned if using ARP. |
|
- | 119 | */ |
|
74 | module_ref arp; |
120 | module_ref arp; |
- | 121 | /** IP version. |
|
- | 122 | */ |
|
75 | int ipv; |
123 | int ipv; |
- | 124 | /** Indicates whether using DHCP. |
|
- | 125 | */ |
|
76 | int dhcp; |
126 | int dhcp; |
- | 127 | /** Indicates whether IP routing is enabled. |
|
- | 128 | */ |
|
77 | int routing; |
129 | int routing; |
- | 130 | /** Device state. |
|
- | 131 | */ |
|
78 | device_state_t state; |
132 | device_state_t state; |
- | 133 | /** Broadcast address. |
|
- | 134 | */ |
|
79 | in_addr_t broadcast; |
135 | in_addr_t broadcast; |
- | 136 | /** First DNS address. |
|
- | 137 | */ |
|
80 | in_addr_t dns1; |
138 | in_addr_t dns1; |
- | 139 | /** Second DNS address. |
|
- | 140 | */ |
|
81 | in_addr_t dns2; |
141 | in_addr_t dns2; |
- | 142 | /** Routing table. |
|
- | 143 | */ |
|
82 | ip_routes_t routes; |
144 | ip_routes_t routes; |
83 | /** Reserved packet prefix length. |
145 | /** Reserved packet prefix length. |
84 | */ |
146 | */ |
85 | size_t prefix; |
147 | size_t prefix; |
86 | /** Maximal packet content length. |
148 | /** Maximal packet content length. |
87 | */ |
149 | */ |
88 | size_t content; |
150 | size_t content; |
89 | /** Reserved packet suffix length. |
151 | /** Reserved packet suffix length. |
90 | */ |
152 | */ |
91 | size_t suffix; |
153 | size_t suffix; |
92 | /** Packet address length. |
154 | /** Packet address length. |
93 | * The hardware address length is used. |
155 | * The hardware address length is used. |
94 | */ |
156 | */ |
95 | size_t addr_len; |
157 | size_t addr_len; |
96 | }; |
158 | }; |
97 | 159 | ||
- | 160 | /** IP protocol specific data. |
|
- | 161 | */ |
|
98 | struct ip_proto{ |
162 | struct ip_proto{ |
- | 163 | /** Protocol number. |
|
- | 164 | */ |
|
99 | int protocol; |
165 | int protocol; |
- | 166 | /** Protocol module service. |
|
- | 167 | */ |
|
100 | services_t service; |
168 | services_t service; |
- | 169 | /** Protocol module phone. |
|
- | 170 | */ |
|
101 | int phone; |
171 | int phone; |
- | 172 | /** Protocol packet receiving function. |
|
- | 173 | */ |
|
102 | tl_received_msg_t received_msg; |
174 | tl_received_msg_t received_msg; |
103 | }; |
175 | }; |
104 | 176 | ||
- | 177 | /** IP route specific data. |
|
- | 178 | */ |
|
105 | struct ip_route{ |
179 | struct ip_route{ |
- | 180 | /** Target address. |
|
- | 181 | */ |
|
106 | in_addr_t address; |
182 | in_addr_t address; |
- | 183 | /** Target network mask. |
|
- | 184 | */ |
|
107 | in_addr_t netmask; |
185 | in_addr_t netmask; |
- | 186 | /** Gateway. |
|
- | 187 | */ |
|
108 | in_addr_t gateway; |
188 | in_addr_t gateway; |
- | 189 | /** Parent netif. |
|
- | 190 | */ |
|
109 | ip_netif_ref netif; |
191 | ip_netif_ref netif; |
110 | }; |
192 | }; |
111 | 193 | ||
- | 194 | /** IP global data. |
|
- | 195 | */ |
|
112 | struct ip_globals{ |
196 | struct ip_globals{ |
- | 197 | /** Networking module phone. |
|
- | 198 | */ |
|
113 | int net_phone; |
199 | int net_phone; |
- | 200 | /** Registered network interfaces. |
|
- | 201 | */ |
|
114 | ip_netifs_t netifs; |
202 | ip_netifs_t netifs; |
- | 203 | /** Netifs safeyt lock. |
|
- | 204 | */ |
|
115 | fibril_rwlock_t netifs_lock; |
205 | fibril_rwlock_t netifs_lock; |
- | 206 | /** Registered protocols. |
|
- | 207 | */ |
|
116 | ip_protos_t protos; |
208 | ip_protos_t protos; |
- | 209 | /** Protocols safety lock. |
|
- | 210 | */ |
|
117 | fibril_rwlock_t protos_lock; |
211 | fibril_rwlock_t protos_lock; |
- | 212 | /** Default gateway. |
|
- | 213 | */ |
|
118 | ip_route_t gateway; |
214 | ip_route_t gateway; |
- | 215 | /** Known support modules. |
|
- | 216 | */ |
|
119 | modules_t modules; |
217 | modules_t modules; |
- | 218 | /** Default client connection function for support modules. |
|
- | 219 | */ |
|
120 | async_client_conn_t client_connection; |
220 | async_client_conn_t client_connection; |
- | 221 | /** Packet counter. |
|
- | 222 | */ |
|
121 | uint16_t packet_counter; |
223 | uint16_t packet_counter; |
- | 224 | /** Safety lock. |
|
- | 225 | */ |
|
122 | fibril_rwlock_t lock; |
226 | fibril_rwlock_t lock; |
123 | }; |
227 | }; |
124 | 228 | ||
125 | #endif |
229 | #endif |
126 | 230 | ||
127 | /** @} |
231 | /** @} |
128 | */ |
232 | */ |
129 | 233 |