Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4163 → Rev 4155

/branches/network/uspace/srv/net/networking/startup/networking_startup.c
67,7 → 67,7
* @returns The started module task identifier.
* @returns Other error codes as defined for the task_spawn() function.
*/
task_id_t spawn( char * fname );
task_id_t spawn( char * const fname );
 
int main( int argc, char * argv[] ){
ERROR_DECLARE;
79,7 → 79,7
ERROR_PROPAGATE( self_test());
// start networking service
if( ! spawn( "/srv/net" )){
printf( "\n" NAME " - Could not spawn networking" );
printf( "\n" NAME "Could not spawn networking" );
return EINVAL;
}
// start networking
89,17 → 89,16
return ERROR_CODE;
}
printf( "\n" NAME " - OK\n" );
 
return EOK;
}
 
task_id_t spawn( char * fname ){
char * argv[ 2 ];
task_id_t spawn( char * const fname ){
char * const argv[ 2 ] = { fname, NULL };
task_id_t res;
 
// printf( "Spawning %s\n", fname );
argv[ 0 ] = fname;
argv[ 1 ] = NULL;
// argv[ 0 ] = fname;
// argv[ 1 ] = NULL;
res = task_spawn( fname, argv );
if( res != 0 ){
/* Success */
/branches/network/uspace/srv/net/networking/networking.c
35,7 → 35,6
 
#include <async.h>
#include <ctype.h>
#include <ddi.h>
#include <errno.h>
#include <malloc.h>
#include <stdio.h>
76,20 → 75,12
#define LO_NAME "lo"
#define LO_FILENAME "/srv/lo"
#define DP8390_NAME "dp8390"
#define DP8390_FILENAME "/srv/dp8390"
#define ETHERNET_NAME "ethernet"
#define ETHERNET_FILENAME "/srv/eth"
#define DP8390_FILENAME "/srv/dp8380"
#define ETHERNET_NAME "ethernet"
#define ETHERNET_FILENAME "/srv/ethernet"
#define IP_NAME "ip"
#define IP_FILENAME "/srv/ip"
 
#define CONF_NAME "NAME"
#define CONF_NETIF "NETIF"
#define CONF_NIL "NIL"
#define CONF_IL "IL"
#define CONF_IRQ "IRQ"
#define CONF_IO "IO"
#define CONF_MTU "MTU"
 
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
#define IPC_GET_COUNT( call ) ( int ) IPC_GET_ARG2( * call )
 
110,10 → 101,10
struct module_struct{
task_id_t task_id;
services_t service;
int phone;
int usage;
char * name;
char * filename;
int phone;
int usage;
const char * name;
const char * filename;
};
 
/** A present network interface device.
157,7 → 148,7
};
 
void networking_print_name( void );
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id );
int add_module( module_ref * module, modules_ref modules, const char const * name, const char const * filename, services_t service, task_id_t task_id );
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
int networking_start_module( async_client_conn_t client_connection );
int networking_initialize( void );
166,7 → 157,7
//int parse_line( measured_strings_ref configuration, char * line );
int add_configuration( measured_strings_ref configuration, const char * name, const char * value );
int read_configuration( void );
task_id_t spawn( char * fname );
task_id_t spawn( const char * const fname );
int startup( void );
device_id_t generate_new_device_id( void );
 
182,7 → 173,7
printf( NAME );
}
 
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id ){
int add_module( module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id ){
ERROR_DECLARE;
 
module_ref tmp_module;
275,7 → 266,7
if( ! task_id ) return EINVAL;
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id ));
// if( ! spawn( "/srv/udp" )) return EINVAL;
// if( ! spawn( "/srv/tcp" )) return EINVAL;
if( ! spawn( "/srv/tcp" )) return EINVAL;
// if( ! spawn( "/srv/socket" )) return EINVAL;
// not always necesssary
// if( ! spawn( "/srv/arp" )) return EINVAL;
441,51 → 432,32
}
 
device_id_t generate_new_device_id( void ){
return device_assign_devno();
return netifs_count( & networking_globals.netifs ) + 1;
}
 
int read_configuration( void ){
ERROR_DECLARE;
 
netif_ref netif;
netif_ref netif;
measured_string_ref setting;
services_t internet_service;
int index;
int irq;
int io;
int mtu;
services_t internet_service;
int index;
 
// read general configuration
ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "IPV", "4" ));
ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "MTU", "1500" ));
 
// read network interfaces configuration
 
// static loopback initialization
// printf( "\nloopback initialization" );
netif = ( netif_ref ) malloc( sizeof( netif_t ));
if( ! netif ) return ENOMEM;
netif->id = generate_new_device_id();
ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration ));
if( ERROR_OCCURRED( add_configuration( & netif->configuration, "NAME", "eth0" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IL", IP_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IRQ", "9" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IO", "300" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.5" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "ARP", "ARP" ))){
measured_strings_destroy( & netif->configuration );
free( netif );
return ERROR_CODE;
}
/* if( ERROR_OCCURRED( add_configuration( & netif->configuration, "NAME", LO_NAME ))
if( ERROR_OCCURRED( add_configuration( & netif->configuration, "NAME", LO_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETIF", LO_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IL", IP_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "MTU", "1500" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){
493,46 → 465,50
free( netif );
return ERROR_CODE;
}
*/ // mandatory name
setting = measured_strings_find( & netif->configuration, CONF_NAME, 0 );
// mandatory name
// printf( "\n\tname" );
setting = measured_strings_find( & netif->configuration, "NAME", 0 );
if( ! setting ){
printf( "\nThe name is missing" );
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
netif->name = setting->value;
// printf( " %s OK", netif->name );
// mandatory netif
setting = measured_strings_find( & netif->configuration, CONF_NETIF, 0 );
// printf( "\n\tnetif" );
setting = measured_strings_find( & netif->configuration, "NETIF", 0 );
if( ! setting ){
printf( "\nThe network interface driver is missing" );
// printf( " unknown" );
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
// printf( " find %s in %d?", setting->value, modules_count( & networking_globals.modules ));
netif->driver = modules_find( & networking_globals.modules, setting->value, 0 );
if( ! netif->driver ){
printf( "\nThe network interface driver is unknown" );
// printf( " not found" );
// TODO register the unknown one
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
// printf( " found" );
if( ! netif->driver->task_id ){
netif->driver->task_id = spawn( netif->driver->filename );
if( ! netif->driver->task_id ){
printf( "\nFailed to start the network interface driver" );
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
}
// optional network interface layer
setting = measured_strings_find( & netif->configuration, CONF_NIL, 0 );
// printf( " OK" );
// optional link layer
// printf( "\n\tlink layer" );
setting = measured_strings_find( & netif->configuration, "NIL", 0 );
if( setting ){
netif->nil = modules_find( & networking_globals.modules, setting->value, 0 );
if( ! netif->nil ){
printf( "\nThe network interface layer is unknown" );
// TODO register the unknown one
-- netif->driver->usage;
measured_strings_destroy( & netif->configuration );
542,7 → 518,6
if( ! netif->nil->task_id ){
netif->nil->task_id = spawn( netif->nil->filename );
if( ! netif->nil->task_id ){
printf( "\nFailed to start the network interface layer" );
-- netif->driver->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
553,9 → 528,9
netif->nil = NULL;
}
// mandatory internet layer
setting = measured_strings_find( & netif->configuration, CONF_IL, 0 );
// printf( "\n\tinternet layer" );
setting = measured_strings_find( & netif->configuration, "IL", 0 );
if( ! setting ){
printf( "\nThe internet layer is missing" );
-- netif->driver->usage;
-- netif->nil->usage;
measured_strings_destroy( & netif->configuration );
562,9 → 537,9
free( netif );
return EINVAL;
}
// printf( " set %s", setting->value );
netif->il = modules_find( & networking_globals.modules, setting->value, 0 );
if( ! netif->il ){
printf( "\nThe internet layer is unknown" );
// TODO register the unknown one
-- netif->driver->usage;
-- netif->nil->usage;
572,10 → 547,10
free( netif );
return EINVAL;
}
// printf( " found" );
if( ! netif->il->task_id ){
netif->il->task_id = spawn( netif->il->filename );
if( ! netif->il->task_id ){
printf( "\nFailed to start the internet layer" );
-- netif->driver->usage;
-- netif->nil->usage;
measured_strings_destroy( & netif->configuration );
586,39 → 561,37
index = netifs_add( & networking_globals.netifs, netif->id, netif );
if( index < 0 ){
free( netif );
return index;
return ERROR_CODE;
}
if( ERROR_OCCURRED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){
netifs_exclude_index( & networking_globals.netifs, index );
return ERROR_CODE;
}
// printf( "\nloopback OK" );
// end of the static loopback initialization
// startup the loopback interface
if( ! netif->driver->phone ){
// printf( " connect?" );
netif->driver->phone = connect_to_service( netif->driver->service );
}
setting = measured_strings_find( & netif->configuration, CONF_IRQ, 0 );
irq = setting ? strtol( setting->value, NULL, 10 ) : 0;
setting = measured_strings_find( & netif->configuration, CONF_IO, 0 );
io = setting ? strtol( setting->value, NULL, 16 ) : 0;
ERROR_PROPAGATE( async_req_3_0( netif->driver->phone, NET_NETIF_PROBE, netif->id, irq, io ));
// printf( " connected" );
// TODO io, irq
ERROR_PROPAGATE( async_req_3_0( netif->driver->phone, NET_NETIF_PROBE, netif->id, 0, 0 ));
++ netif->driver->usage;
if( netif->nil ){
if( ! netif->nil->phone ){
netif->nil->phone = connect_to_service( netif->nil->service );
}
setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 );
if( ! setting ){
setting = measured_strings_find( & networking_globals.configuration, CONF_MTU, 0 );
}
mtu = setting ? strtol( setting->value, NULL, 10 ) : 0;
ERROR_PROPAGATE( async_req_3_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, netif->driver->service, mtu ));
ERROR_PROPAGATE( async_req_2_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, netif->driver->service ));
++ netif->nil->usage;
internet_service = netif->nil->service;
// printf( " OK" );
}else{
internet_service = netif->driver->service;
// printf( " none" );
}
if( ! netif->il->phone ){
// printf( " connect" );
netif->il->phone = connect_to_service( netif->il->service );
}
// TODO IL_BUNDLE
626,25 → 599,18
++ netif->il->usage;
// TODO startup?
ERROR_PROPAGATE( async_req_1_0( netif->driver->phone, NET_NETIF_START, netif->id ));
printf( "\nNew network interface started:\n\tname\t= %s\n\tid\t= %d\n\tdriver\t= %s\n\tnil\t= %s\n\til\t= %s", netif->name, netif->id, netif->driver->name, netif->nil ? netif->nil->name : NULL, netif->il->name );
// printf( "\n LO OK" );
return EOK;
}
 
task_id_t spawn( char * fname ){
char * argv[ 2 ];
// char * argv[ 4 ];
task_id_t spawn( const char * const fname ){
char * const argv[ 2 ] = { fname, NULL };
task_id_t res;
 
// printf( "Spawning %s\n", fname );
argv[ 0 ] = fname;
argv[ 1 ] = NULL;
// argv[ 0 ] = fname;
// argv[ 1 ] = NULL;
res = task_spawn( fname, argv );
/* argv[ 0 ] = "/app/trace";
argv[ 1 ] = "+ti";
argv[ 2 ] = fname;
argv[ 3 ] = NULL;
res = task_spawn( "/app/trace", argv );
*/
if( res != 0 ){
/* Success */
usleep( 50000 );
/branches/network/uspace/srv/net/nil/eth/eth.c
157,14 → 157,14
// an existing device?
device = eth_devices_find( & eth_globals.devices, device_id );
if( device ){
if( device->service != service ){
printf( "\nDevice %d already exists", device->device_id );
if( device->service == service ){
// update mtu
device->mtu = mtu;
rwlock_write_unlock( & eth_globals.devices_lock );
return EOK;
}else{
rwlock_write_unlock( & eth_globals.devices_lock );
return EEXIST;
}else{
// update mtu
device->mtu = mtu;
printf( "\nDevice %d already exists:\tMTU\t= %d", device->device_id, device->mtu );
}
}else{
// create a new device
172,16 → 172,11
if( ! device ) return ENOMEM;
device->device_id = device_id;
device->service = service;
device->mtu = ( mtu > 0 ) ? mtu : ETH_MAX_CONTENT;
device->mtu = mtu;
// TODO get dummy setting
device->dummy = 0;
// bind the device driver
device->phone = bind_service( device->service, device->device_id, SERVICE_ETHERNET, 0, eth_receiver );
if( device->phone < 0 ){
rwlock_write_unlock( & eth_globals.devices_lock );
free( device );
return device->phone;
}
// get hardware address
message = async_send_1( device->phone, NET_NETIF_GET_ADDR, device->device_id, & answer );
if( ERROR_OCCURRED( measured_strings_return( device->phone, & device->addr, & device->addr_data, 1 ))){
206,7 → 201,6
free( device );
return ERROR_CODE;
}
printf( "\nNew device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X", device->device_id, device->service, device->mtu, device->addr_data[ 0 ], device->addr_data[ 1 ], device->addr_data[ 2 ], device->addr_data[ 3 ], device->addr_data[ 4 ], device->addr_data[ 5 ] );
}
rwlock_write_unlock( & eth_globals.devices_lock );
return EOK;
309,7 → 303,7
rwlock_write_unlock( & eth_globals.devices_lock );
return ENOENT;
}
* content = ( ETH_MAX_CONTENT > device->mtu ) ? device->mtu : ETH_MAX_CONTENT;
* content = ( ETH_MAX_CONTENT > device->mtu ) ? device->mtu : ETH_MAX_CONTENT;
rwlock_write_unlock( & eth_globals.devices_lock );
* addr_len = ETH_ADDR;
* prefix = ETH_PREFIX;
365,7 → 359,6
return ERROR_CODE;
}
}
printf( "\nNew protocol registered:\n\tprotocol\t= %d\n\tservice\t= %d\n\tphone\t= %d", proto->protocol, proto->service, proto->phone );
rwlock_write_unlock( & eth_globals.protos_lock );
return EOK;
}
/branches/network/uspace/srv/net/netif/dp8390/dp8390_module.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/ne2000.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/dp8390.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/dp8390_drv.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/ne2000.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/dp8390.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/dp8390_module.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/Makefile
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/local.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/dp8390/dp8390_port.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/lo/lo.c
55,11 → 55,6
 
netif_globals_t netif_globals;
 
static struct lo_globals{
measured_string_ref addr;
int mtu;
} lo_globals;
 
int change_state_message( device_id_t device_id, device_state_t state );
int create( device_id_t device_id, device_ref * device );
int initialize( void );
69,12 → 64,7
int send_message( device_id_t device_id, packet_t packet );
int start_message( device_id_t device_id );
int stop_message( device_id_t device_id );
measured_string_ref get_addr_message( device_id_t device_id );
 
measured_string_ref get_addr_message( device_id_t device_id ){
return lo_globals.addr;
}
 
int change_state_message( device_id_t device_id, device_state_t state ){
ERROR_DECLARE;
 
84,7 → 74,6
if( device->state != state ){
device->state = state;
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL );
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
}
return EOK;
}
102,6 → 91,8
( ** device ).specific = NULL;
null_device_stats( &(( ** device ).stats ));
( ** device ).state = NETIF_STOPPED;
( ** device ).flags = NULL;
( ** device ).mtu = DEFAULT_MTU;
if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
free( * device );
* device = NULL;
114,8 → 105,6
int initialize( void ){
ipcarg_t phonehash;
 
lo_globals.addr = measured_string_create_bulk( "\0\0\0\0\0\0", 0 );
if( ! lo_globals.addr ) return ENOMEM;
return REGISTER_ME( SERVICE_LO, & phonehash );
}
 
156,16 → 145,16
}
// MTU is the first one
if( settings && ( settings[ 0 ].value )){
lo_globals.mtu = strtoul( settings[ 0 ].value, NULL, 0 );
device->mtu = strtoul( settings[ 0 ].value, NULL, 0 );
}else{
lo_globals.mtu = DEFAULT_MTU;
device->mtu = DEFAULT_MTU;
}
// print the settings
printf("\n -MTU =\t%d", device->mtu );
free( settings );
free( data );
// end request
async_wait_for( message, NULL );
// print the settings
printf("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
return EOK;
}
 
/branches/network/uspace/srv/net/netif/lo/Makefile
40,7 → 40,7
../$(NAME).c \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)measured_strings.h \
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet.c
 
/branches/network/uspace/srv/net/netif/netif.c
34,7 → 34,6
*/
 
#include <async.h>
#include <mem.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
47,7 → 46,6
 
#include "../structures/packet/packet.h"
#include "../structures/packet/packet_client.h"
#include "../structures/measured_strings.h"
 
#include "device.h"
#include "netif.h"
66,7 → 64,6
extern int send_message( device_id_t device_id, packet_t packet );
extern int start_message( device_id_t device_id );
extern int stop_message( device_id_t device_id );
extern measured_string_ref get_addr_message( device_id_t device_id );
 
DEVICE_MAP_IMPLEMENT( device_map, device_t )
 
75,9 → 72,7
int register_message( device_id_t device_id, int phone );
int get_device_stats( device_id_t device_id, device_stats_ref * stats );
 
 
int find_device( device_id_t device_id, device_ref * device ){
if( ! device ) return EBADMEM;
* device = device_map_find( & netif_globals.device_map, device_id );
if( ! * device ) return ENOENT;
if(( ** device ).state == NETIF_NULL ) return EPERM;
89,7 → 84,7
 
device_ref device;
 
if( ! stats ) return EBADMEM;
if( ! stats ) return EINVAL;
ERROR_PROPAGATE( find_device( device_id, & device ));
* stats = & device->stats;
return EOK;
96,7 → 91,31
}
 
void null_device_stats( device_stats_ref stats ){
bzero( stats, sizeof( device_stats_t ));
memset( stats, 0, sizeof( device_stats_t ));
/* stats->rx_packets = 0;
stats->tx_packets = 0;
stats->rx_bytes = 0;
stats->tx_bytes = 0;
stats->rx_errors = 0;
stats->tx_errors = 0;
stats->rx_dropped = 0;
stats->tx_dropped = 0;
stats->multicast = 0;
stats->collisions = 0;
stats->rx_length_errors = 0;
stats->rx_over_errors = 0;
stats->rx_crc_errors = 0;
stats->rx_frame_errors = 0;
stats->rx_fifo_errors = 0;
stats->rx_missed_errors = 0;
stats->tx_aborted_errors = 0;
stats->tx_carrier_errors = 0;
stats->tx_fifo_errors = 0;
stats->tx_heartbeat_errors = 0;
stats->tx_window_errors = 0;
stats->rx_compressed = 0;
stats->tx_compressed = 0;
*/
}
 
int register_message( device_id_t device_id, int phone ){
105,9 → 124,8
device_ref device;
 
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->nil_phone > 0 ) return ELIMIT;
if( device->nil_phone ) return ELIMIT;
device->nil_phone = phone;
printf( "\nNew receiver of the device %d registered:\n\tphone\t= %d", device->device_id, device->nil_phone );
return EOK;
}
 
114,10 → 132,9
int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
size_t length;
size_t length;
device_stats_ref stats;
packet_t packet;
measured_string_ref address;
packet_t packet;
 
// printf( "\nNETIF message %d", method );
* answer_count = 0;
142,9 → 159,6
return ipc_data_read_finalize( callid, stats, sizeof( device_stats_t ));
case NET_NETIF_STOP:
return stop_message( IPC_GET_DEVICE( call ));
case NET_NETIF_GET_ADDR:
address = get_addr_message( IPC_GET_DEVICE( call ));
return address ? measured_strings_reply( address, 1 ) : ENOENT;
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/netif/netif.h
85,6 → 85,14
/** Actual device state.
*/
device_state_t state;
// TODO needed?
/** Various device flags.
*/
int flags;
/** Maximum transmission unit.
* The maximum packet content to be transmited.
*/
size_t mtu;
/** Driver specific data.
*/
void * specific;
/branches/network/uspace/srv/net/il/arp/arp.c
198,7 → 198,6
device = arp_cache_find( & arp_globals.cache, device_id );
if( device ){
if( device->service != service ){
printf( "\nDevice %d already exists", device->device_id );
rwlock_write_unlock( & arp_globals.lock );
return EEXIST;
}
219,7 → 218,7
return ERROR_CODE;
}
}
printf( "\nCache of the existing device %d cleaned", device->device_id );
return EOK;
}else{
// create a new device
device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
292,7 → 291,6
free( device );
return ERROR_CODE;
}
printf( "\nNew device registered:\n\tid\t= %d\n\ttype\t= %x\n\tservice\t= %d", device->device_id, device->hardware, device->service );
}
rwlock_write_unlock( & arp_globals.lock );
return EOK;
444,7 → 442,6
return ENOENT;
}
clear_device( device );
printf( "\nDevice %d cleared", device_id );
rwlock_write_unlock( & arp_globals.lock );
return EOK;
}
479,8 → 476,7
}
}
arp_cache_clear( & arp_globals.cache );
rwlock_write_unlock( & arp_globals.lock );
printf( "\nCache cleaned" );
rwlock_write_lock( & arp_globals.lock );
return EOK;
}
 
/branches/network/uspace/srv/net/il/ip/ip.c
142,7 → 142,6
// TODO ARP module
}
// TODO arp module
// TODO register
free( settings );
free( data );
// end request
149,23 → 148,23
// TODO mapping
async_wait_for( message, NULL );
// print the settings
printf( "\nNew device registered:\n\tid\t= %d\n\tphone\t= %d\n\tIPV\t= %d", ip_netif->device_id, ip_netif->phone, ip_netif->ipv );
printf( "\n\tconfiguration\t= %s", ip_netif->dhcp ? "dhcp" : "static" );
printf( "\n -IPV =\t%d", ip_netif->ipv );
printf( "\n -configuration =\t%s", ip_netif->dhcp ? "dhcp" : "static" );
// TODO ipv6
data = malloc( INET_ADDRSTRLEN );
if( data ){
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->address, data, INET_ADDRSTRLEN );
printf( "\n\taddress\t= %s", data );
printf( "\n -address =\t%s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN );
printf( "\n\tnetmask\t= %s", data );
printf( "\n -netmask =\t%s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN );
printf( "\n\tgateway\t= %s", data );
printf( "\n -gateway =\t%s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN );
printf( "\n\tbroadcast\t= %s", data );
printf( "\n -broadcast =\t%s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
printf( "\n\tdns1\t= %s", data );
printf( "\n -dns1 =\t%s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
printf( "\n\tdns2\t= %s", data );
printf( "\n -dns2 =\t%s", data );
free( data );
}
// TODO mapping
241,7 → 240,6
free( proto );
return ERROR_CODE;
}
printf( "\nNew protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d", proto->protocol, proto->phone );
return EOK;
}