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