Rev 4704 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4704 | Rev 4720 | ||
---|---|---|---|
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 net |
29 | /** @addtogroup net |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * Networking subsystem central module. |
34 | * Networking subsystem central module. |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_NET_H__ |
37 | #ifndef __NET_NET_H__ |
38 | #define __NET_NET_H__ |
38 | #define __NET_NET_H__ |
39 | 39 | ||
40 | #include <ipc/ipc.h> |
40 | #include <ipc/ipc.h> |
41 | 41 | ||
42 | #include "../include/device.h" |
42 | #include "../include/device.h" |
43 | 43 | ||
44 | #include "../structures/char_map.h" |
44 | #include "../structures/char_map.h" |
45 | #include "../structures/generic_char_map.h" |
45 | #include "../structures/generic_char_map.h" |
46 | #include "../structures/measured_strings.h" |
46 | #include "../structures/measured_strings.h" |
47 | #include "../structures/module_map.h" |
47 | #include "../structures/module_map.h" |
48 | #include "../structures/packet/packet.h" |
48 | #include "../structures/packet/packet.h" |
49 | 49 | ||
50 | /** @name Modules definitions |
50 | /** @name Modules definitions |
51 | */ |
51 | */ |
52 | /*@{*/ |
52 | /*@{*/ |
53 | 53 | ||
54 | /** Loopback network interface module name. |
54 | /** Loopback network interface module name. |
55 | */ |
55 | */ |
56 | #define LO_NAME "lo" |
56 | #define LO_NAME "lo" |
57 | 57 | ||
58 | /** Loopback network interface module full path filename. |
58 | /** Loopback network interface module full path filename. |
59 | */ |
59 | */ |
60 | #define LO_FILENAME "/srv/lo" |
60 | #define LO_FILENAME "/srv/lo" |
61 | 61 | ||
62 | /** DP8390 network interface module name. |
62 | /** DP8390 network interface module name. |
63 | */ |
63 | */ |
64 | #define DP8390_NAME "dp8390" |
64 | #define DP8390_NAME "dp8390" |
65 | 65 | ||
66 | /** DP8390 network interface module full path filename. |
66 | /** DP8390 network interface module full path filename. |
67 | */ |
67 | */ |
68 | #define DP8390_FILENAME "/srv/dp8390" |
68 | #define DP8390_FILENAME "/srv/dp8390" |
69 | 69 | ||
70 | /** Ethernet module name. |
70 | /** Ethernet module name. |
71 | */ |
71 | */ |
72 | #define ETHERNET_NAME "ethernet" |
72 | #define ETHERNET_NAME "ethernet" |
73 | 73 | ||
74 | /** Ethernet module full path filename. |
74 | /** Ethernet module full path filename. |
75 | */ |
75 | */ |
76 | #define ETHERNET_FILENAME "/srv/eth" |
76 | #define ETHERNET_FILENAME "/srv/eth" |
77 | 77 | ||
78 | /** Ethernet module name. |
78 | /** Ethernet module name. |
79 | */ |
79 | */ |
80 | #define NILDUMMY_NAME "nildummy" |
80 | #define NILDUMMY_NAME "nildummy" |
81 | 81 | ||
82 | /** Ethernet module full path filename. |
82 | /** Ethernet module full path filename. |
83 | */ |
83 | */ |
84 | #define NILDUMMY_FILENAME "/srv/nildummy" |
84 | #define NILDUMMY_FILENAME "/srv/nildummy" |
85 | 85 | ||
86 | /** IP module name. |
86 | /** IP module name. |
87 | */ |
87 | */ |
88 | #define IP_NAME "ip" |
88 | #define IP_NAME "ip" |
89 | 89 | ||
90 | /** IP module full path filename. |
90 | /** IP module full path filename. |
91 | */ |
91 | */ |
92 | #define IP_FILENAME "/srv/ip" |
92 | #define IP_FILENAME "/srv/ip" |
93 | 93 | ||
94 | /*@}*/ |
94 | /*@}*/ |
95 | 95 | ||
96 | /** @name Configuration setting names definitions |
96 | /** @name Configuration setting names definitions |
97 | */ |
97 | */ |
98 | /*@{*/ |
98 | /*@{*/ |
99 | 99 | ||
100 | /** Network interface name configuration label. |
100 | /** Network interface name configuration label. |
101 | */ |
101 | */ |
102 | #define CONF_NAME "NAME" |
102 | #define CONF_NAME "NAME" |
103 | 103 | ||
104 | /** Network interface module name configuration label. |
104 | /** Network interface module name configuration label. |
105 | */ |
105 | */ |
106 | #define CONF_NETIF "NETIF" |
106 | #define CONF_NETIF "NETIF" |
107 | 107 | ||
108 | /** Network interface layer module name configuration label. |
108 | /** Network interface layer module name configuration label. |
109 | */ |
109 | */ |
110 | #define CONF_NIL "NIL" |
110 | #define CONF_NIL "NIL" |
111 | 111 | ||
112 | /** Internet protocol module name configuration label. |
112 | /** Internet protocol module name configuration label. |
113 | */ |
113 | */ |
114 | #define CONF_IL "IL" |
114 | #define CONF_IL "IL" |
115 | 115 | ||
116 | /** Interrupt number configuration label. |
116 | /** Interrupt number configuration label. |
117 | */ |
117 | */ |
118 | #define CONF_IRQ "IRQ" |
118 | #define CONF_IRQ "IRQ" |
119 | 119 | ||
120 | /** Device input/output address configuration label. |
120 | /** Device input/output address configuration label. |
121 | */ |
121 | */ |
122 | #define CONF_IO "IO" |
122 | #define CONF_IO "IO" |
123 | 123 | ||
124 | /** Maximum transmission unit configuration label. |
124 | /** Maximum transmission unit configuration label. |
125 | */ |
125 | */ |
126 | #define CONF_MTU "MTU" |
126 | #define CONF_MTU "MTU" |
127 | 127 | ||
128 | /*@}*/ |
128 | /*@}*/ |
129 | 129 | ||
130 | /** Type definition of the network interface specific data. |
130 | /** Type definition of the network interface specific data. |
131 | * @see netif |
131 | * @see netif |
132 | */ |
132 | */ |
133 | typedef struct netif netif_t; |
133 | typedef struct netif netif_t; |
134 | 134 | ||
135 | /** Type definition of the network interface specific data pointer. |
135 | /** Type definition of the network interface specific data pointer. |
136 | * @see netif |
136 | * @see netif |
137 | */ |
137 | */ |
138 | typedef netif_t * netif_ref; |
138 | typedef netif_t * netif_ref; |
139 | 139 | ||
140 | /** Type definition of the networking module global data. |
140 | /** Type definition of the networking module global data. |
141 | * @see net_globals |
141 | * @see net_globals |
142 | */ |
142 | */ |
143 | typedef struct net_globals net_globals_t; |
143 | typedef struct net_globals net_globals_t; |
144 | 144 | ||
145 | /** Present network interfaces. |
145 | /** Present network interfaces. |
146 | * Maps devices to the networking device specific data. |
146 | * Maps devices to the networking device specific data. |
147 | * @see device.h |
147 | * @see device.h |
148 | */ |
148 | */ |
149 | DEVICE_MAP_DECLARE( netifs, netif_t ) |
149 | DEVICE_MAP_DECLARE( netifs, netif_t ) |
150 | 150 | ||
151 | /** Configuration settings. |
151 | /** Configuration settings. |
152 | * Maps setting names to the values. |
152 | * Maps setting names to the values. |
153 | * @see generic_char_map.h |
153 | * @see generic_char_map.h |
154 | */ |
154 | */ |
155 | GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t ) |
155 | GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t ) |
156 | 156 | ||
157 | /** Present network interface device. |
157 | /** Present network interface device. |
158 | */ |
158 | */ |
159 | struct netif{ |
159 | struct netif{ |
160 | /** System-unique network interface identifier. |
160 | /** System-unique network interface identifier. |
161 | */ |
161 | */ |
162 | device_id_t id; |
162 | device_id_t id; |
163 | /** Serving network interface driver module index. |
163 | /** Serving network interface driver module index. |
164 | */ |
164 | */ |
165 | module_ref driver; |
165 | module_ref driver; |
166 | /** Serving link layer module index. |
166 | /** Serving link layer module index. |
167 | */ |
167 | */ |
168 | module_ref nil; |
168 | module_ref nil; |
169 | /** Serving internet layer module index. |
169 | /** Serving internet layer module index. |
170 | */ |
170 | */ |
171 | module_ref il; |
171 | module_ref il; |
172 | /** System-unique network interface name. |
172 | /** System-unique network interface name. |
173 | */ |
173 | */ |
174 | char * name; |
174 | char * name; |
175 | /** Configuration. |
175 | /** Configuration. |
176 | */ |
176 | */ |
177 | measured_strings_t configuration; |
177 | measured_strings_t configuration; |
178 | }; |
178 | }; |
179 | 179 | ||
180 | /** Networking module global variables. |
180 | /** Networking module global variables. |
181 | */ |
181 | */ |
182 | struct net_globals{ |
182 | struct net_globals{ |
183 | /** Present network interfaces. |
183 | /** Present network interfaces. |
184 | */ |
184 | */ |
185 | netifs_t netifs; |
185 | netifs_t netifs; |
186 | /** Network interface structure indices by names. |
186 | /** Network interface structure indices by names. |
187 | */ |
187 | */ |
188 | char_map_t netif_names; |
188 | char_map_t netif_names; |
189 | /** Available modules. |
189 | /** Available modules. |
190 | */ |
190 | */ |
191 | modules_t modules; |
191 | modules_t modules; |
192 | /** Global configuration. |
192 | /** Global configuration. |
193 | */ |
193 | */ |
194 | measured_strings_t configuration; |
194 | measured_strings_t configuration; |
195 | }; |
195 | }; |
196 | 196 | ||
197 | /** Adds the configured setting to the configuration map. |
197 | /** Adds the configured setting to the configuration map. |
198 | * @param configuration The configuration map. Input parameter. |
198 | * @param configuration The configuration map. Input parameter. |
199 | * @param name The setting name. Input parameter. |
199 | * @param name The setting name. Input parameter. |
200 | * @param value The setting value. Input parameter. |
200 | * @param value The setting value. Input parameter. |
201 | * @returns EOK on success. |
201 | * @returns EOK on success. |
202 | * @returns ENOMEM if there is not enough memory left. |
202 | * @returns ENOMEM if there is not enough memory left. |
203 | */ |
203 | */ |
204 | int add_configuration( measured_strings_ref configuration, const char * name, const char * value ); |
204 | int add_configuration( measured_strings_ref configuration, const char * name, const char * value ); |
205 | 205 | ||
206 | /** Processes the networking message. |
206 | /** Processes the networking message. |
207 | * @param callid The message identifier. Input parameter. |
207 | * @param callid The message identifier. Input parameter. |
208 | * @param call The message parameters. Input parameter. |
208 | * @param call The message parameters. Input parameter. |
209 | * @param answer The message answer parameters. Output parameter. |
209 | * @param answer The message answer parameters. Output parameter. |
210 | * @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter. |
210 | * @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter. |
211 | * @returns EOK on success. |
211 | * @returns EOK on success. |
212 | * @returns ENOTSUP if the message is not known. |
212 | * @returns ENOTSUP if the message is not known. |
213 | * @see net_interface.h |
213 | * @see net_interface.h |
214 | * @see IS_NET_NET_MESSAGE() |
214 | * @see IS_NET_NET_MESSAGE() |
215 | */ |
215 | */ |
216 | int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
216 | int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
217 | 217 | ||
218 | /** Initializes the networking module. |
218 | /** Initializes the networking module for the chosen subsystem build type. |
219 | * @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter. |
219 | * @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter. |
220 | * @returns EOK on success. |
220 | * @returns EOK on success. |
221 | * @returns ENOMEM if there is not enough memory left. |
221 | * @returns ENOMEM if there is not enough memory left. |
222 | */ |
222 | */ |
223 | int net_initialize( async_client_conn_t client_connection ); |
223 | int net_initialize_build( async_client_conn_t client_connection ); |
224 | 224 | ||
225 | /** Processes the module message. |
225 | /** Processes the module message. |
226 | * Distributes the message to the right bundled module. |
226 | * Distributes the message to the right bundled module. |
227 | * @param callid The message identifier. Input parameter. |
227 | * @param callid The message identifier. Input parameter. |
228 | * @param call The message parameters. Input parameter. |
228 | * @param call The message parameters. Input parameter. |
229 | * @param answer The message answer parameters. Output parameter. |
229 | * @param answer The message answer parameters. Output parameter. |
230 | * @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter. |
230 | * @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter. |
231 | * @returns EOK on success. |
231 | * @returns EOK on success. |
232 | * @returns ENOTSUP if the message is not known. |
232 | * @returns ENOTSUP if the message is not known. |
233 | * @returns Other error codes as defined for each bundled module message function. |
233 | * @returns Other error codes as defined for each bundled module message function. |
234 | */ |
234 | */ |
235 | int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
235 | int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
236 | 236 | ||
237 | /** Reads the network interface specific configuration. |
237 | /** Reads the network interface specific configuration for the chosen subsystem build type. |
238 | * @param name The network interface name. Input parameter. |
238 | * @param name The network interface name. Input parameter. |
239 | * @param netif The network interface structure. Input/output parameter. |
239 | * @param netif The network interface structure. Input/output parameter. |
240 | * @returns EOK on success. |
240 | * @returns EOK on success. |
241 | * @returns Other error codes as defined for the add_configuration() function. |
241 | * @returns Other error codes as defined for the add_configuration() function. |
242 | */ |
242 | */ |
243 | int read_netif_configuration( char * name, netif_ref netif ); |
243 | int read_netif_configuration_build( char * name, netif_ref netif ); |
244 | 244 | ||
245 | #endif |
245 | #endif |
246 | 246 | ||
247 | /** @} |
247 | /** @} |
248 | */ |
248 | */ |
249 | 249 |