Subversion Repositories HelenOS

Rev

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