Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4349 → Rev 4350

/branches/network/uspace/srv/net/netif/netif_module.h
30,6 → 30,12
* @{
*/
 
/** @file
* Network interface module interface.
* The interface has to be implemented by each network interface module.
* The interface is used by the network interface module skeleton.
*/
 
#ifndef __NET_NETIF_MODULE_H__
#define __NET_NETIF_MODULE_H__
 
41,14 → 47,70
 
#include "../include/device.h"
 
/** Initializes the specific module.
*/
int netif_initialize( void );
 
/** Automatically probes all known devices.
*/
int netif_probe_auto_message( void );
 
/** Probes the existence of the device.
* @param device_id The device identifier. Input parameter.
* @param irq The device interrupt number. Input parameter.
* @param io The device input/output address. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_probe_message( device_id_t device_id, int irq, int io );
 
/** Sends the packet queue.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_send_message( device_id_t device_id, packet_t packet, services_t sender );
 
/** Starts the device.
* @param device The device structure. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_start_message( device_ref device );
 
/** Stops the device.
* @param device The device structure. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_stop_message( device_ref device );
 
/** Returns the device local hardware address.
* @param device_id The device identifier. Input parameter.
* @param address The device local hardware address. Output parameter.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_get_addr_message( device_id_t device_id, measured_string_ref address );
 
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Returns the device usage statistics.
* @param device_id The device identifier. Input parameter.
* @param stats The device usage statistics. Output parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
*/
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats );
 
#endif
/branches/network/uspace/srv/net/netif/netif_nil_bundle.c
30,6 → 30,11
* @{
*/
 
/** @file
* Wrapper for the bundled network interface and network interface layer module.
* Distributes messages and initializes both module parts.
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
42,9 → 47,27
 
#include "netif.h"
 
/** Network interface module global data.
*/
extern netif_globals_t netif_globals;
 
/** Distributes the messages between the module parts.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
*/
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Starts the bundle network interface module.
* Initializes the client connection serving function, initializes both module parts, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
int module_start( async_client_conn_t client_connection );
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
/branches/network/uspace/srv/net/netif/netif_remote.c
30,6 → 30,11
* @{
*/
 
/** @file
* Network interface module interface implementation for standalone remote modules.
* @see netif_interface.h
*/
 
#include <ipc/services.h>
 
#include "../modules.h"
/branches/network/uspace/srv/net/netif/netif.c
31,6 → 31,8
*/
 
/** @file
* Network interface module skeleton implementation.
* @see netif.h
*/
 
#include <async.h>
57,10 → 59,19
#include "netif_messages.h"
#include "netif_module.h"
 
/** Network interface module global data.
*/
extern netif_globals_t netif_globals;
 
DEVICE_MAP_IMPLEMENT( device_map, device_t )
 
/** Registers the device notification receiver, the network interface layer module.
* @param device_id The device identifier. Input parameter.
* @param phone The network interface layer module phone. Input parameter.
* @returns EOK on success.
* @returns ENOENT if there is no such device.
* @returns ELIMIT if there is another module registered.
*/
int register_message( device_id_t device_id, int phone );
 
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){
/branches/network/uspace/srv/net/netif/dp8390/local.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Medjrech ported to HelenOS
* 2009 Lukas Mejdrech ported to HelenOS
*/
 
/** @addtogroup dp8390
/branches/network/uspace/srv/net/netif/dp8390/ne2000.c
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Medjrech ported to HelenOS
* 2009 Lukas Mejdrech ported to HelenOS
*/
 
/** @addtogroup ne2k
28,6 → 28,10
* @{
*/
 
/** @file
*
*/
 
#include <stdio.h>
#include <unistd.h>
 
/branches/network/uspace/srv/net/netif/dp8390/ne2000.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Medjrech ported to HelenOS
* 2009 Lukas Mejdrech ported to HelenOS
*/
 
/*
/branches/network/uspace/srv/net/netif/dp8390/Makefile
52,8 → 52,9
ifeq ($(NETWORKING), module)
 
SOURCES += ../$(NAME)_nil_bundle.c \
$(NET_BASE)nil/eth/eth.c \
$(NET_BASE)crc.c \
$(NET_BASE)nil/eth/eth.c
$(NET_BASE)net/net_remote.c
 
else
 
/branches/network/uspace/srv/net/netif/dp8390/dp8390.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Medjrech ported to HelenOS
* 2009 Lukas Mejdrech ported to HelenOS
*/
 
/** @addtogroup dp8390
/branches/network/uspace/srv/net/netif/lo/lo.c
31,6 → 31,7
*/
 
/** @file
* Loopback network interface implementation.
*/
 
#include <async.h>
54,21 → 55,52
#include "../netif.h"
#include "../netif_module.h"
 
/** Default maximum transmission unit.
*/
#define DEFAULT_MTU 1500
 
/** Default hardware address.
*/
#define DEFAULT_ADDR "\0\0\0\0\0\0"
 
/** Default address length.
*/
#define DEFAULT_ADDR_LEN ( sizeof( DEFAULT_ADDR ) / sizeof( char ))
 
/** Loopback module name.
*/
#define NAME "lo - loopback interface"
 
/** Network interface global data.
*/
netif_globals_t netif_globals;
 
/** Loopback module global data.
*/
static struct lo_globals{
unsigned int mtu;
} lo_globals;
 
static int change_state_message( device_ref device, device_state_t state );
static int create( device_id_t device_id, device_ref * device );
/** Changes the loopback state.
* @param device The device structure. Input parameter.
* @param state The new device state. Input parameter.
* @returns The new state if changed.
* @returns EOK otherwise.
*/
int change_state_message( device_ref device, device_state_t state );
 
/** Creates and returns the loopback network interface structure.
* @param device_id The new devce identifier. Input parameter.
* @param device The device structure. Output parameter.
* @returns EOK on success.
* @returns EXDEV if one loopback network interface already exists.
* @returns ENOMEM if there is not enough memory left.
*/
int create( device_id_t device_id, device_ref * device );
 
/** Prints the module name.
* @see NAME
*/
void module_print_name( void );
 
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
94,7 → 126,7
return EOK;
}
 
static int change_state_message( device_ref device, device_state_t state ){
int change_state_message( device_ref device, device_state_t state ){
if( device->state != state ){
device->state = state;
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
103,7 → 135,7
return EOK;
}
 
static int create( device_id_t device_id, device_ref * device ){
int create( device_id_t device_id, device_ref * device ){
int index;
 
if( device_map_count( & netif_globals.device_map ) > 0 ){
/branches/network/uspace/srv/net/netif/netif.h
32,6 → 32,8
 
/** @file
* Network interface module skeleton.
* The skeleton has to be part of each network interface module.
* The skeleton can be also part of the module bundled with the network interface layer.
*/
 
#ifndef __NET_NETIF_H__
114,16 → 116,42
void null_device_stats( device_stats_ref stats );
 
// prepared for future optimalizations
/** \todo
/** Releases the given packet.
* @param packet_id The packet identifier. Input parameter.
*/
void netif_pq_release( packet_id_t packet );
void netif_pq_release( packet_id_t packet_id );
 
/** \todo
/** Allocates new packet to handle the given content size.
* @param content The minimum content size. Input parameter.
* @returns The allocated packet.
* @returns NULL if there is an error.
*/
packet_t netif_packet_get_1( size_t content );
 
/** Processes the netif module messages.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
* @see netif_interface.h
* @see IS_NET_NETIF_MESSAGE()
*/
int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Initializes the netif module.
* The function has to be defined in each module.
* @param client_connection The client connection functio to be registered. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
int netif_init_module( async_client_conn_t client_connection );
 
/** Starts and maintains the netif module until terminated.
* @returns EOK after the module is terminated.
*/
int netif_run_module( void );
 
#endif
/branches/network/uspace/srv/net/netif/netif_standalone.c
30,6 → 30,10
* @{
*/
 
/** @file
* Wrapper for the standalone network interface module.
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
36,9 → 40,23
 
#include "netif.h"
 
extern netif_globals_t netif_globals;
/** Delegates the messages to the netif_message() function.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
*/
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
/** Starts the network interface module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
int module_start( async_client_conn_t client_connection );
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){