Rev 4720 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4307 | mejdrech | 1 | /* |
2 | * Copyright (c) 2009 Lukas Mejdrech |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
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 |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
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 |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
29 | /** @addtogroup net |
||
30 | * @{ |
||
31 | */ |
||
32 | |||
33 | /** @file |
||
4350 | mejdrech | 34 | * Networking subsystem central module. |
4307 | mejdrech | 35 | */ |
36 | |||
37 | #ifndef __NET_NET_H__ |
||
38 | #define __NET_NET_H__ |
||
39 | |||
40 | #include <ipc/ipc.h> |
||
41 | |||
42 | #include "../include/device.h" |
||
43 | |||
44 | #include "../structures/char_map.h" |
||
45 | #include "../structures/generic_char_map.h" |
||
46 | #include "../structures/measured_strings.h" |
||
47 | #include "../structures/module_map.h" |
||
48 | #include "../structures/packet/packet.h" |
||
49 | |||
4704 | mejdrech | 50 | /** @name Modules definitions |
51 | */ |
||
52 | /*@{*/ |
||
53 | |||
4350 | mejdrech | 54 | /** Loopback network interface module name. |
55 | */ |
||
4307 | mejdrech | 56 | #define LO_NAME "lo" |
4350 | mejdrech | 57 | |
58 | /** Loopback network interface module full path filename. |
||
59 | */ |
||
4307 | mejdrech | 60 | #define LO_FILENAME "/srv/lo" |
4350 | mejdrech | 61 | |
62 | /** DP8390 network interface module name. |
||
63 | */ |
||
4307 | mejdrech | 64 | #define DP8390_NAME "dp8390" |
4350 | mejdrech | 65 | |
66 | /** DP8390 network interface module full path filename. |
||
67 | */ |
||
4307 | mejdrech | 68 | #define DP8390_FILENAME "/srv/dp8390" |
4350 | mejdrech | 69 | |
70 | /** Ethernet module name. |
||
71 | */ |
||
4307 | mejdrech | 72 | #define ETHERNET_NAME "ethernet" |
4350 | mejdrech | 73 | |
74 | /** Ethernet module full path filename. |
||
75 | */ |
||
4307 | mejdrech | 76 | #define ETHERNET_FILENAME "/srv/eth" |
4350 | mejdrech | 77 | |
4696 | mejdrech | 78 | /** Ethernet module name. |
79 | */ |
||
80 | #define NILDUMMY_NAME "nildummy" |
||
81 | |||
82 | /** Ethernet module full path filename. |
||
83 | */ |
||
84 | #define NILDUMMY_FILENAME "/srv/nildummy" |
||
85 | |||
4704 | mejdrech | 86 | /** IP module name. |
4350 | mejdrech | 87 | */ |
4307 | mejdrech | 88 | #define IP_NAME "ip" |
4350 | mejdrech | 89 | |
4704 | mejdrech | 90 | /** IP module full path filename. |
4350 | mejdrech | 91 | */ |
4307 | mejdrech | 92 | #define IP_FILENAME "/srv/ip" |
93 | |||
4704 | mejdrech | 94 | /*@}*/ |
95 | |||
96 | /** @name Configuration setting names definitions |
||
97 | */ |
||
98 | /*@{*/ |
||
99 | |||
4350 | mejdrech | 100 | /** Network interface name configuration label. |
101 | */ |
||
4307 | mejdrech | 102 | #define CONF_NAME "NAME" |
4350 | mejdrech | 103 | |
104 | /** Network interface module name configuration label. |
||
105 | */ |
||
4307 | mejdrech | 106 | #define CONF_NETIF "NETIF" |
4350 | mejdrech | 107 | |
108 | /** Network interface layer module name configuration label. |
||
109 | */ |
||
4307 | mejdrech | 110 | #define CONF_NIL "NIL" |
4350 | mejdrech | 111 | |
112 | /** Internet protocol module name configuration label. |
||
113 | */ |
||
4307 | mejdrech | 114 | #define CONF_IL "IL" |
4350 | mejdrech | 115 | |
116 | /** Interrupt number configuration label. |
||
117 | */ |
||
4307 | mejdrech | 118 | #define CONF_IRQ "IRQ" |
4350 | mejdrech | 119 | |
120 | /** Device input/output address configuration label. |
||
121 | */ |
||
4307 | mejdrech | 122 | #define CONF_IO "IO" |
4350 | mejdrech | 123 | |
124 | /** Maximum transmission unit configuration label. |
||
125 | */ |
||
4307 | mejdrech | 126 | #define CONF_MTU "MTU" |
127 | |||
4704 | mejdrech | 128 | /*@}*/ |
129 | |||
4350 | mejdrech | 130 | /** Type definition of the network interface specific data. |
131 | * @see netif |
||
132 | */ |
||
4307 | mejdrech | 133 | typedef struct netif netif_t; |
4350 | mejdrech | 134 | |
135 | /** Type definition of the network interface specific data pointer. |
||
136 | * @see netif |
||
137 | */ |
||
4307 | mejdrech | 138 | typedef netif_t * netif_ref; |
139 | |||
4350 | mejdrech | 140 | /** Type definition of the networking module global data. |
141 | * @see net_globals |
||
142 | */ |
||
4307 | mejdrech | 143 | typedef struct net_globals net_globals_t; |
144 | |||
4350 | mejdrech | 145 | /** Present network interfaces. |
146 | * Maps devices to the networking device specific data. |
||
147 | * @see device.h |
||
148 | */ |
||
4307 | mejdrech | 149 | DEVICE_MAP_DECLARE( netifs, netif_t ) |
150 | |||
4350 | mejdrech | 151 | /** Configuration settings. |
152 | * Maps setting names to the values. |
||
153 | * @see generic_char_map.h |
||
154 | */ |
||
4307 | mejdrech | 155 | GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t ) |
156 | |||
4350 | mejdrech | 157 | /** Present network interface device. |
4307 | mejdrech | 158 | */ |
159 | struct netif{ |
||
4350 | mejdrech | 160 | /** System-unique network interface identifier. |
4307 | mejdrech | 161 | */ |
162 | device_id_t id; |
||
4350 | mejdrech | 163 | /** Serving network interface driver module index. |
4307 | mejdrech | 164 | */ |
165 | module_ref driver; |
||
4350 | mejdrech | 166 | /** Serving link layer module index. |
4307 | mejdrech | 167 | */ |
168 | module_ref nil; |
||
4350 | mejdrech | 169 | /** Serving internet layer module index. |
4307 | mejdrech | 170 | */ |
171 | module_ref il; |
||
4350 | mejdrech | 172 | /** System-unique network interface name. |
4307 | mejdrech | 173 | */ |
174 | char * name; |
||
175 | /** Configuration. |
||
176 | */ |
||
177 | measured_strings_t configuration; |
||
178 | }; |
||
179 | |||
4350 | mejdrech | 180 | /** Networking module global variables. |
4307 | mejdrech | 181 | */ |
182 | struct net_globals{ |
||
183 | /** Present network interfaces. |
||
184 | */ |
||
185 | netifs_t netifs; |
||
186 | /** Network interface structure indices by names. |
||
187 | */ |
||
188 | char_map_t netif_names; |
||
189 | /** Available modules. |
||
190 | */ |
||
191 | modules_t modules; |
||
192 | /** Global configuration. |
||
193 | */ |
||
194 | measured_strings_t configuration; |
||
195 | }; |
||
196 | |||
4350 | mejdrech | 197 | /** Adds the configured setting to the configuration map. |
4756 | mejdrech | 198 | * @param[in] configuration The configuration map. |
199 | * @param[in] name The setting name. |
||
200 | * @param[in] value The setting value. |
||
4350 | mejdrech | 201 | * @returns EOK on success. |
202 | * @returns ENOMEM if there is not enough memory left. |
||
203 | */ |
||
4307 | mejdrech | 204 | int add_configuration( measured_strings_ref configuration, const char * name, const char * value ); |
4350 | mejdrech | 205 | |
206 | /** Processes the networking message. |
||
4756 | mejdrech | 207 | * @param[in] callid The message identifier. |
208 | * @param[in] call The message parameters. |
||
209 | * @param[out] answer The message answer parameters. |
||
210 | * @param[out] answer_count The last parameter for the actual answer in the answer parameter. |
||
4350 | mejdrech | 211 | * @returns EOK on success. |
212 | * @returns ENOTSUP if the message is not known. |
||
213 | * @see net_interface.h |
||
214 | * @see IS_NET_NET_MESSAGE() |
||
215 | */ |
||
4307 | mejdrech | 216 | int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
4350 | mejdrech | 217 | |
4720 | mejdrech | 218 | /** Initializes the networking module for the chosen subsystem build type. |
4756 | mejdrech | 219 | * @param[in] client_connection The client connection processing function. The module skeleton propagates its own one. |
4350 | mejdrech | 220 | * @returns EOK on success. |
221 | * @returns ENOMEM if there is not enough memory left. |
||
222 | */ |
||
4720 | mejdrech | 223 | int net_initialize_build( async_client_conn_t client_connection ); |
4350 | mejdrech | 224 | |
225 | /** Processes the module message. |
||
226 | * Distributes the message to the right bundled module. |
||
4756 | mejdrech | 227 | * @param[in] callid The message identifier. |
228 | * @param[in] call The message parameters. |
||
229 | * @param[out] answer The message answer parameters. |
||
230 | * @param[out] answer_count The last parameter for the actual answer in the answer parameter. |
||
4350 | mejdrech | 231 | * @returns EOK on success. |
232 | * @returns ENOTSUP if the message is not known. |
||
233 | * @returns Other error codes as defined for each bundled module message function. |
||
234 | */ |
||
4307 | mejdrech | 235 | int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
4350 | mejdrech | 236 | |
4720 | mejdrech | 237 | /** Reads the network interface specific configuration for the chosen subsystem build type. |
4756 | mejdrech | 238 | * @param[in] name The network interface name. |
239 | * @param[in,out] netif The network interface structure. |
||
4350 | mejdrech | 240 | * @returns EOK on success. |
241 | * @returns Other error codes as defined for the add_configuration() function. |
||
242 | */ |
||
4720 | mejdrech | 243 | int read_netif_configuration_build( char * name, netif_ref netif ); |
4307 | mejdrech | 244 | |
245 | #endif |
||
246 | |||
247 | /** @} |
||
248 | */ |