Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4271 → Rev 4307

/branches/network/uspace/srv/net/networking/networking.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/Makefile
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/startup/networking_startup.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/startup/Makefile
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/startup
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/tl/tcp/tcp.c
44,7 → 44,7
#include "../../modules.h"
#include "../../structures/packet/packet_client.h"
 
#include "../../il/ip/ip_messages.h"
#include "../../include/ip_interface.h"
 
#include "tcp.h"
#include "tcp_module.h"
54,22 → 54,22
/** Initializes the module.
*/
int tcp_initialize( void ){
ERROR_DECLARE;
// ERROR_DECLARE;
 
ipcarg_t arg1, arg2;
// ipcarg_t arg1, arg2;
packet_t packet;
 
printf( "\nTCP - testing to send to IP:\t" );
/* printf( "TCP - testing to send to IP:\n" );
ERROR_PROPAGATE( ip_echo( tcp_globals.ip_phone, 12, 34, 0, 0, 0, & arg1, & arg2, NULL, NULL, NULL ));
if(( arg1 != 12 ) || ( arg2 != 34 )) return EINVAL;
printf( "OK\n" );
 
printf( "\nTCP - testing to send packet to IP:\t" );
packet = packet_get_4( tcp_globals.networking_phone, 6, 20, 30, 20 );
*/
printf( "TCP - testing to send packet to IP:\n" );
packet = packet_get_4( tcp_globals.net_phone, 6, 20, 30, 20 );
if( ! packet ) return ENOMEM;
packet_copy_data( packet, "Hi, this is TCP", 16 );
ip_send( tcp_globals.ip_phone, -1, packet );
printf( "\tOK\n" );
ip_send_msg( tcp_globals.ip_phone, -1, packet, SERVICE_TCP );
printf( "OK\n" );
return EOK;
}
 
/branches/network/uspace/srv/net/tl/tcp/tcp.h
40,7 → 40,7
 
struct tcp_globals{
int ip_phone;
int networking_phone;
int net_phone;
};
 
#endif
/branches/network/uspace/srv/net/tl/tcp/tcp_module.c
44,7 → 44,9
 
#include "../../structures/packet/packet.h"
 
#include "../../include/protocols.h"
#include "../../include/net_interface.h"
#include "../../include/ip_protocols.h"
#include "../../include/ip_interface.h"
 
#include "tcp.h"
#include "tcp_module.h"
51,23 → 53,24
 
#define NAME "TCP protocol"
 
void tcp_print_name( void );
int tcp_start_module( async_client_conn_t client_connection );
void module_print_name( void );
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 );
 
extern tcp_globals_t tcp_globals;
 
void tcp_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
int tcp_start_module( async_client_conn_t client_connection ){
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
tcp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
tcp_globals.ip_phone = bind_service( SERVICE_IP, IPPROTO_TCP, 0, 0, client_connection );
tcp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
tcp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_TCP, client_connection );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( tcp_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_TCP, & phonehash ))){
81,5 → 84,9
return EOK;
}
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
return tcp_message( callid, call, answer, answer_count );
}
 
/** @}
*/
/branches/network/uspace/srv/net/tl/tcp/Makefile
41,8 → 41,10
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet_remote.c \
$(STRUCTURES)measured_strings.c \
$(NET_BASE)il/ip/ip_remote.c \
$(NET_BASE)net/net_remote.c
 
NET_DEFS += -D TCP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/nil/nil_wrappers.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/nil/nil_messages.h
0,0 → 1,70
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net_nil
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NIL_MESSAGES_H__
#define __NET_NIL_MESSAGES_H__
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
typedef enum {
/* ( device_id, driver_service, mtu ) */
NET_NIL_DEVICE = NET_NIL_FIRST,
/* ( device_id, state ) */
NET_NIL_DEVICE_STATE,
/* ( device_id ), packet_send */
NET_NIL_RECEIVED,
/* ( device_id ), packet_send */
NET_NIL_SEND,
/* ( device_id ) -> addr, prefix, content, suffix */
NET_NIL_PACKET_SPACE,
/* ( device_id ), measured_strings_return( hardware address ) */
NET_NIL_ADDR,
/* ( device_id ), measured_strings_return( broadcast address ) */
NET_NIL_BROADCAST_ADDR,
} nil_messages;
 
/** Returns the protocol service message parameter.
*/
#define NIL_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call )
 
#define NIL_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/nil/eth/eth.c
53,14 → 53,14
#include "../../include/ethernet_protocols.h"
#include "../../include/protocol_map.h"
#include "../../include/device.h"
#include "../../include/netif_messages.h"
#include "../../include/nil_messages.h"
#include "../../include/netif_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
 
#include "../../structures/measured_strings.h"
#include "../../structures/packet/packet_client.h"
 
#include "../nil_module.h"
#include "../nil_wrappers.h"
 
#include "eth.h"
#include "eth_header.h"
95,7 → 95,8
INT_MAP_IMPLEMENT( eth_protos, eth_proto_t )
 
int eth_device_message( device_id_t device_id, services_t service, size_t mtu );
int eth_receive_message( device_id_t device_id, packet_t packet );
int nil_receive_msg( int nil_phone, device_id_t device_id, packet_t packet );
int nil_register_message( services_t service, int phone );
int eth_packet_space_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
int eth_addr_message( device_id_t device_id, eth_addr_type_t type, measured_string_ref * address );
int eth_send_message( device_id_t device_id, packet_t packet, services_t sender );
102,7 → 103,7
eth_proto_ref eth_process_packet( int dummy, packet_t packet );
int eth_prepare_packet( int dummy, packet_t packet, uint8_t * src_addr, int ethertype );
 
void nil_device_state_wrapper( device_id_t device_id, int state ){
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state ){
int index;
eth_proto_ref proto;
 
110,16 → 111,13
rwlock_read_lock( & eth_globals.protos_lock );
for( index = eth_protos_count( & eth_globals.protos ) - 1; index >= 0; -- index ){
proto = eth_protos_get_index( & eth_globals.protos, index );
if( proto && proto->phone ) async_msg_2( proto->phone, NET_IL_DEVICE_STATE, device_id, state );
if( proto && proto->phone ) il_device_state_msg( proto->phone, device_id, state );
}
rwlock_read_unlock( & eth_globals.protos_lock );
return EOK;
}
 
int nil_receive_wrapper( device_id_t device_id, packet_t packet ){
return eth_receive_message( device_id, packet );
}
 
int nil_initialize( int networking_phone ){
int nil_initialize( int net_phone ){
ERROR_DECLARE;
 
rwlock_initialize( & eth_globals.devices_lock );
126,7 → 124,7
rwlock_initialize( & eth_globals.protos_lock );
rwlock_write_lock( & eth_globals.devices_lock );
rwlock_write_lock( & eth_globals.protos_lock );
eth_globals.networking_phone = networking_phone;
eth_globals.net_phone = net_phone;
eth_globals.broadcast_addr = measured_string_create_bulk( "\xFF\xFF\xFF\xFF\xFF\xFF", CONVERT_SIZE( uint8_t, char, ETH_ADDR ));
if( ! eth_globals.broadcast_addr ) return ENOMEM;
ERROR_PROPAGATE( eth_devices_initialize( & eth_globals.devices ));
150,13 → 148,13
device = eth_devices_find( & eth_globals.devices, device_id );
if( device ){
if( device->service != service ){
printf( "\nDevice %d already exists", device->device_id );
printf( "Device %d already exists\n", device->device_id );
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 );
printf( "Device %d already exists:\tMTU\t= %d\n", device->device_id, device->mtu );
}
}else{
// create a new device
168,14 → 166,12
// TODO get dummy setting
device->dummy = 0;
// bind the device driver
#if ! NETIF_BUNDLE
device->phone = bind_service( device->service, device->device_id, SERVICE_ETHERNET, 0, eth_receiver );
device->phone = netif_bind_service( device->service, device->device_id, SERVICE_ETHERNET, eth_receiver );
if( device->phone < 0 ){
rwlock_write_unlock( & eth_globals.devices_lock );
free( device );
return device->phone;
}
#endif
// get hardware address
if( ERROR_OCCURRED( netif_get_addr( device->phone, device->device_id, & device->addr, & device->addr_data ))){
rwlock_write_unlock( & eth_globals.devices_lock );
191,7 → 187,7
free( device );
return index;
}
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 ] );
printf( "New device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X\n", 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;
254,7 → 250,7
return eth_protos_find( & eth_globals.protos, type );
}
 
int eth_receive_message( device_id_t device_id, packet_t packet ){
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target ){
eth_proto_ref proto;
packet_t next;
eth_device_ref device;
273,10 → 269,10
next = pq_detach( packet );
proto = eth_process_packet( dummy, packet );
if( proto ){
async_msg_3( proto->phone, NET_IL_RECEIVED, device_id, packet_get_id( packet ), proto->service );
il_received_msg( proto->phone, device_id, packet, proto->service );
}else{
// drop invalid/unknown
pq_release( eth_globals.networking_phone, packet_get_id( packet ));
pq_release( eth_globals.net_phone, packet_get_id( packet ));
}
packet = next;
}while( packet );
350,7 → 346,7
return index;
}
}
printf( "\nNew protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d", proto->protocol, proto->service, proto->phone );
printf( "New protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d\n", proto->protocol, proto->service, proto->phone );
rwlock_write_unlock( & eth_globals.protos_lock );
return EOK;
}
409,7 → 405,7
 
ethertype = htons( protocol_map( SERVICE_ETHERNET, sender ));
if( ! ethertype ){
pq_release( eth_globals.networking_phone, packet_get_id( packet ));
pq_release( eth_globals.net_phone, packet_get_id( packet ));
return EINVAL;
}
rwlock_read_lock( & eth_globals.devices_lock );
424,7 → 420,7
if( ERROR_OCCURRED( eth_prepare_packet( device->dummy, next, ( uint8_t * ) device->addr->value, ethertype ))){
// release invalid packet
tmp = pq_detach( next );
pq_release( eth_globals.networking_phone, packet_get_id( next ));
pq_release( eth_globals.net_phone, packet_get_id( next ));
next = tmp;
}else{
next = pq_next( next );
442,7 → 438,7
measured_string_ref address;
packet_t packet;
 
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_NIL_FIRST );
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NIL_FIRST );
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
450,7 → 446,7
case NET_NIL_DEVICE:
return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), NIL_GET_MTU( call ));
case NET_NIL_SEND:
ERROR_PROPAGATE( packet_translate( eth_globals.networking_phone, & packet, IPC_GET_PACKET( call )));
ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
case NET_NIL_PACKET_SPACE:
ERROR_PROPAGATE( eth_packet_space_message( IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
476,12 → 472,12
while( true ){
switch( IPC_GET_METHOD( * icall )){
case NET_NIL_DEVICE_STATE:
nil_device_state_wrapper( IPC_GET_DEVICE( icall ), IPC_GET_STATE( icall ));
nil_device_state_msg( 0, IPC_GET_DEVICE( icall ), IPC_GET_STATE( icall ));
ipc_answer_0( iid, EOK );
break;
case NET_NIL_RECEIVED:
if( ! ERROR_OCCURRED( packet_translate( eth_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){
ERROR_CODE = nil_receive_wrapper( IPC_GET_DEVICE( icall ), packet );
if( ! ERROR_OCCURRED( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){
ERROR_CODE = nil_received_msg( 0, IPC_GET_DEVICE( icall ), packet, 0 );
}
ipc_answer_0( iid, ERROR_CODE );
break;
/branches/network/uspace/srv/net/nil/eth/eth.h
126,7 → 126,7
struct eth_globals{
/** Networking module phone.
*/
int networking_phone;
int net_phone;
/** Safety lock for devices.
*/
rwlock_t devices_lock;
/branches/network/uspace/srv/net/nil/eth/eth_module.c
42,6 → 42,8
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "../nil_module.h"
50,25 → 52,26
 
#define NAME "Ethernet protocol"
 
void eth_print_name( void );
int eth_start_module( async_client_conn_t client_connection );
void module_print_name( void );
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 );
 
extern eth_globals_t eth_globals;
 
void eth_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
int eth_start_module( async_client_conn_t client_connection ){
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
int networking_phone;
int net_phone;
 
async_set_client_connection( client_connection );
networking_phone = connect_to_service( SERVICE_NETWORKING );
net_phone = net_connect_module( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( nil_initialize( networking_phone ))
if( ERROR_OCCURRED( nil_initialize( net_phone ))
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ETHERNET, & phonehash ))){
pm_destroy();
return ERROR_CODE;
80,5 → 83,9
return EOK;
}
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
return nil_message( callid, call, answer, answer_count );
}
 
/** @}
*/
/branches/network/uspace/srv/net/nil/eth/Makefile
35,13 → 35,15
SOURCES = \
$(NAME)_module.c \
$(NAME).c \
$(REBUILD) \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(NET_BASE)crc.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c
$(STRUCTURES)/packet/packet_client.c \
$(STRUCTURES)packet/packet_remote.c \
$(NET_BASE)netif/netif_remote.c \
$(NET_BASE)net/net_remote.c
 
NET_DEFS += -D NIL_BUNDLE=1 -Dnil_message=$(NAME)_message
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/nil/nil_module.h
40,7 → 40,6
 
int nil_initialize( int networking_phone );
int nil_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int nil_register_message( services_t service, int phone );
 
#endif
 
/branches/network/uspace/srv/net/nil/nil_remote.c
0,0 → 1,52
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net_nil
* @{
*/
 
#include "../messages.h"
 
#include "../include/device.h"
#include "../include/nil_interface.h"
 
#include "../structures/packet/packet.h"
#include "../structures/packet/packet_client.h"
 
#include "nil_messages.h"
 
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state ){
return generic_device_state_msg( nil_phone, NET_NIL_DEVICE_STATE, device_id, state );
}
 
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target ){
return generic_received_msg( nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id( packet ), target );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/structures/module_map.c
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
/** @addtogroup net
* @{
*/
 
48,7 → 48,7
 
GENERIC_CHAR_MAP_IMPLEMENT( modules, module_t )
 
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, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t connect_module ){
ERROR_DECLARE;
 
module_ref tmp_module;
61,6 → 61,7
tmp_module->name = name;
tmp_module->filename = filename;
tmp_module->service = service;
tmp_module->connect_module = connect_module;
if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module ))){
free( tmp_module );
return ERROR_CODE;
80,7 → 81,7
if( ! module->task_id ) return NULL;
}
if( ! module->phone ){
module->phone = connect_to_service( module->service );
module->phone = module->connect_module( module->service );
}
return module;
}
/branches/network/uspace/srv/net/structures/measured_strings.h
38,6 → 38,8
#ifndef __MEASURED_STRINGS_H__
#define __MEASURED_STRINGS_H__
 
#include <sys/types.h>
 
/** Type definition of the character string with measured length.
* @see measured_string
*/
/branches/network/uspace/srv/net/structures/packet/packet_remote.c
0,0 → 1,125
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup packet
* @{
*/
 
/**
* @file
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
#include <sys/mman.h>
 
#include "../../err.h"
#include "../../messages.h"
 
#include "packet.h"
#include "packet_client.h"
#include "packet_messages.h"
 
/** Obtains the packet from the packet server as the shared memory block.
* Creates the local packet mapping as well.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference pointer to store the received packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param size The packet total size in bytes. Input parameter.
* @returns EOK on success.
* \todo ipc_share_in_start() error?
* @returns Other error codes as defined for the pm_add() function.
*/
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size );
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
ERROR_DECLARE;
 
unsigned int size;
 
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
if( * packet ) return EOK;
ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
return packet_return( phone, packet, packet_id, size );
}
 
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
ERROR_DECLARE;
 
aid_t message;
ipc_call_t answer;
ipcarg_t result;
 
message = async_send_1( phone, NET_PACKET_GET, packet_id, & answer );
* packet = ( packet_t ) as_get_mappable_page( size );
if( ERROR_OCCURRED( ipc_share_in_start_0_0( phone, * packet, size ))
|| ERROR_OCCURRED( pm_add( * packet ))){
munmap( * packet, size );
async_wait_for( message, NULL );
return ERROR_CODE;
}
async_wait_for( message, & result );
return result;
}
 
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
packet_t packet_get_1( int phone, size_t content ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
void pq_release( int phone, packet_id_t packet_id ){
async_msg_1( phone, NET_PACKET_RELEASE, packet_id );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_messages.h
0,0 → 1,78
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup packet
* @{
*/
 
/** @file
*/
 
#ifndef __NET_PACKET_MESSAGES__
#define __NET_PACKET_MESSAGES__
 
#include <ipc/ipc.h>
 
#include "../../messages.h"
 
typedef enum {
NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
NET_PACKET_CREATE_4,
NET_PACKET_GET,
NET_PACKET_GET_SIZE,
NET_PACKET_RELEASE
} packet_messages;
 
/** Returns the protocol service message parameter.
*/
#define ARP_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call )
 
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal content length message parameter.
*/
#define IPC_GET_CONTENT( call ) ( size_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal address length message parameter.
*/
#define IPC_GET_ADDR_LEN( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the maximal prefix length message parameter.
*/
#define IPC_GET_PREFIX( call ) ( size_t ) IPC_GET_ARG3( * call )
 
/** Returns the maximal suffix length message parameter.
*/
#define IPC_GET_SUFFIX( call ) ( size_t ) IPC_GET_ARG4( * call )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_header.h
37,6 → 37,8
#ifndef __NET_PACKET_HEADER_H__
#define __NET_PACKET_HEADER_H__
 
#include "../../messages.h"
 
#include "packet.h"
 
/** Packet integrity check magic value.
/branches/network/uspace/srv/net/structures/packet/packet_client.c
50,18 → 50,6
#include "packet_header.h"
#include "packet_client.h"
 
/** Obtains the packet from the packet server as the shared memory block.
* Creates the local packet mapping as well.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference pointer to store the received packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param size The packet total size in bytes. Input parameter.
* @returns EOK on success.
* \todo ipc_share_in_start() error?
* @returns Other error codes as defined for the pm_add() function.
*/
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size );
 
int packet_copy_data( packet_t packet, const void * data, size_t length ){
if( ! packet_is_valid( packet )) return EINVAL;
if( packet->data_start + length >= packet->length ) return ENOMEM;
135,68 → 123,5
return EOK;
}
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
ERROR_DECLARE;
 
unsigned int size;
 
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
if( * packet ) return EOK;
ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
return packet_return( phone, packet, packet_id, size );
}
 
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
ERROR_DECLARE;
 
aid_t message;
ipc_call_t answer;
ipcarg_t result;
 
message = async_send_1( phone, NET_PACKET_GET, packet_id, & answer );
* packet = ( packet_t ) as_get_mappable_page( size );
if( ERROR_OCCURRED( ipc_share_in_start_0_0( phone, * packet, size ))
|| ERROR_OCCURRED( pm_add( * packet ))){
munmap( * packet, size );
async_wait_for( message, NULL );
return ERROR_CODE;
}
async_wait_for( message, & result );
return result;
}
 
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
packet_t packet_get_1( int phone, size_t content ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
void pq_release( int phone, packet_id_t packet_id ){
async_msg_1( phone, NET_PACKET_RELEASE, packet_id );
}
 
/** @}
*/
/branches/network/uspace/srv/net/structures/packet/packet_server.c
48,9 → 48,13
#include "../../messages.h"
 
#include "packet.h"
#include "packet_client.h"
#include "packet_header.h"
#include "packet_messages.h"
#include "packet_server.h"
 
#define FREE_QUEUES_COUNT 7
 
/** The default address length reserved for new packets.
*/
#define DEFAULT_ADDR_LEN 32
63,28 → 67,6
*/
#define DEFAULT_SUFFIX 0
 
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal content length message parameter.
*/
#define IPC_GET_CONTENT( call ) ( size_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal address length message parameter.
*/
#define IPC_GET_ADDR_LEN( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the maximal prefix length message parameter.
*/
#define IPC_GET_PREFIX( call ) ( size_t ) IPC_GET_ARG3( * call )
 
/** Returns the maximal suffix length message parameter.
*/
#define IPC_GET_SUFFIX( call ) ( size_t ) IPC_GET_ARG4( * call )
 
#define FREE_QUEUES_COUNT 7
 
/** Packet server global data.
*/
static struct{
109,12 → 91,6
0
};
 
/** Releases the packet and returns it to the appropriate free packet queue.
* Should be used only when the global data are locked.
* @param packet The packet to be released. Input parameter.
*/
void packet_release( packet_t packet );
 
/** Returns the packet of dimensions at least as given.
* Tries to reuse free packets first.
* Creates a&nbsp;new packet aligned to the memory page size if none available.
126,8 → 102,18
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** \todo
*/
int packet_release_wrapper( packet_id_t packet_id );
 
/** Releases the packet and returns it to the appropriate free packet queue.
* Should be used only when the global data are locked.
* @param packet The packet to be released. Input parameter.
*/
void packet_release( packet_t packet );
 
/** Creates a&nbsp;new packet of dimensions at least as given.
* Should be used only when the global data are locked.
* @param length The total length of the packet, including the header, the addresses and the data of the packet. Input parameter.
159,6 → 145,24
*/
int packet_reply( const packet_t packet );
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
return ( * packet ) ? EOK : ENOENT;
}
 
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
return packet_get( addr_len, max_prefix, max_content, max_suffix );
}
 
packet_t packet_get_1( int phone, size_t content ){
return packet_get( DEFAULT_ADDR_LEN, DEFAULT_PREFIX, content, DEFAULT_SUFFIX );
}
 
void pq_release( int phone, packet_id_t packet_id ){
( void ) packet_release_wrapper( packet_id );
}
 
int packet_server_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
packet_t packet;
 
191,16 → 195,22
IPC_SET_ARG1( * answer, packet->length );
return EOK;
case NET_PACKET_RELEASE:
packet = pm_find( IPC_GET_ID( call ));
if( ! packet_is_valid( packet )) return ENOENT;
futex_down( & ps_globals.lock );
pq_destroy( packet, packet_release );
futex_up( & ps_globals.lock );
return EOK;
return packet_release_wrapper( IPC_GET_ID( call ));
}
return ENOTSUP;
}
 
int packet_release_wrapper( packet_id_t packet_id ){
packet_t packet;
 
packet = pm_find( packet_id );
if( ! packet_is_valid( packet )) return ENOENT;
futex_down( & ps_globals.lock );
pq_destroy( packet, packet_release );
futex_up( & ps_globals.lock );
return EOK;
}
 
void packet_release( packet_t packet ){
int index;
 
/branches/network/uspace/srv/net/structures/module_map.h
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
/** @addtogroup net
* @{
*/
 
41,6 → 41,8
 
#include <ipc/services.h>
 
#include "../modules.h"
 
#include "generic_char_map.h"
 
typedef struct module_struct module_t;
55,9 → 57,10
int usage;
char * name;
char * filename;
connect_module_t * connect_module;
};
 
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, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
module_ref get_running_module( modules_ref modules, char * name );
task_id_t spawn( char * fname );
 
/branches/network/uspace/srv/net/include/netif_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/nil_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/protocols.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/arp_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/nil_interface.h
0,0 → 1,76
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net_nil
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NIL_INTERFACE_H__
#define __NET_NIL_INTERFACE_H__
 
#include <async.h>
#include <errno.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
 
#include "../nil/nil_messages.h"
 
#include "device.h"
 
#define nil_get_addr( nil_phone, device_id, address, data ) \
generic_get_addr( nil_phone, NET_NIL_ADDR, device_id, address, data )
 
#define nil_get_broadcast_addr( nil_phone, device_id, address, data ) \
generic_get_addr( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data )
 
#define nil_send_msg( nil_phone, device_id, packet, sender ) \
generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender )
 
#define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix ) \
generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix )
 
#define nil_device_req( nil_phone, device_id, mtu, netif_service ) \
generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
 
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state );
 
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/include/arp_interface.h
0,0 → 1,53
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup arp
* @{
*/
 
/** @file
*/
 
#ifndef __NET_ARP_INTERFACE_H__
#define __NET_ARP_INTERFACE_H__
 
#include "../structures/measured_strings.h"
 
#include "device.h"
 
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address );
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data );
int arp_clear_device_req( int arp_phone, device_id_t device_id );
int arp_clean_cache_req( int arp_phone );
int arp_connect_module( services_t service );
int arp_task_get_id( void );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/include/net_interface.h
0,0 → 1,55
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*/
 
#ifndef __NET_NET_INTERFACE_H__
#define __NET_NET_INTERFACE_H__
 
//#include <async.h>
 
#include <ipc/services.h>
 
#include "../include/device.h"
 
#include "../structures/measured_strings.h"
 
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data );
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data );
void net_free_settings( measured_string_ref settings, char * data );
int net_connect_module( services_t service );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/ip_protocols.h
0,0 → 1,614
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/** @file
* Internet protocol numbers according to the on-line IANA - Assigned Protocol numbers - <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml>, cited January 14 2009.
* Names according to the linux src/include/linux/in.h header file.
*/
 
#ifndef __NET_IPPROTOCOLS_H__
#define __NET_IPPROTOCOLS_H__
 
/** IPv6 Hop-by-Hop Option internet protocol number.
*/
#define IPPROTO_HOPOPT 0
 
/** Internet Control Message internet protocol number.
*/
#define IPPROTO_ICMP 1
 
/** Internet Group Management internet protocol number.
*/
#define IPPROTO_IGMP 2
 
/** Gateway-to-Gateway internet protocol number.
*/
#define IPPROTO_GGP 3
 
/** IP in IP (encapsulation) internet protocol number.
*/
#define IPPROTO_IP 4
 
/** Stream internet protocol number.
*/
#define IPPROTO_ST 5
 
/** Transmission Control internet protocol number.
*/
#define IPPROTO_TCP 6
 
/** CBT internet protocol number.
*/
#define IPPROTO_CBT 7
 
/** Exterior Gateway Protocol internet protocol number.
*/
#define IPPROTO_EGP 8
 
/** any private interior gateway
(used by Cisco for their IGRP) internet protocol number.
*/
#define IPPROTO_IGP 9
 
/** BBN RCC Monitoring internet protocol number.
*/
#define IPPROTO_BBN_RCC_MON 10
 
/** Network Voice Protocol internet protocol number.
*/
#define IPPROTO_NVP_II 11
 
/** PUP internet protocol number.
*/
#define IPPROTO_PUP 12
 
/** ARGUS internet protocol number.
*/
#define IPPROTO_ARGUS 13
 
/** EMCON internet protocol number.
*/
#define IPPROTO_EMCON 14
 
/** Cross Net Debugger internet protocol number.
*/
#define IPPROTO_XNET 15
 
/** Chaos internet protocol number.
*/
#define IPPROTO_CHAOS 16
 
/** User Datagram internet protocol number.
*/
#define IPPROTO_UDP 17
 
/** Multiplexing internet protocol number.
*/
#define IPPROTO_MUX 18
 
/** DCN Measurement Subsystems internet protocol number.
*/
#define IPPROTO_DCN_MEAS 19
 
/** Host Monitoring internet protocol number.
*/
#define IPPROTO_HMP 20
 
/** Packet Radio Measurement internet protocol number.
*/
#define IPPROTO_PRM 21
 
/** XEROX NS IDP internet protocol number.
*/
#define IPPROTO_XNS_IDP 22
 
/** Trunk-1 internet protocol number.
*/
#define IPPROTO_TRUNK_1 23
 
/** Trunk-2 internet protocol number.
*/
#define IPPROTO_TRUNK_2 24
 
/** Leaf-1 internet protocol number.
*/
#define IPPROTO_LEAF_1 25
 
/** Leaf-2 internet protocol number.
*/
#define IPPROTO_LEAF_2 26
 
/** Reliable Data Protocol internet protocol number.
*/
#define IPPROTO_RDP 27
 
/** Internet Reliable Transaction internet protocol number.
*/
#define IPPROTO_IRTP 28
 
/** ISO Transport Protocol Class 4 internet protocol number.
*/
#define IPPROTO_ISO_TP4 29
 
/** Bulk Data Transfer Protocol internet protocol number.
*/
#define IPPROTO_NETBLT 30
 
/** MFE Network Services Protocol internet protocol number.
*/
#define IPPROTO_MFE_NSP 31
 
/** MERIT Internodal Protocol internet protocol number.
*/
#define IPPROTO_MERIT_INP 32
 
/** Datagram Congestion Control Protocol internet protocol number.
*/
#define IPPROTO_DCCP 33
 
/** Third Party Connect Protocol internet protocol number.
*/
#define IPPROTO_3PC 34
 
/** Inter-Domain Policy Routing Protocol internet protocol number.
*/
#define IPPROTO_IDPR 35
 
/** XTP internet protocol number.
*/
#define IPPROTO_XTP 36
 
/** Datagram Delivery Protocol internet protocol number.
*/
#define IPPROTO_DDP 37
 
/** IDPR Control Message Transport Proto internet protocol number.
*/
#define IPPROTO_IDPR_CMTP 38
 
/** TP++ Transport Protocol internet protocol number.
*/
#define IPPROTO_TP 39
 
/** IL Transport Protocol internet protocol number.
*/
#define IPPROTO_IL 40
 
/** Ipv6 internet protocol number.
*/
#define IPPROTO_IPV6 41
 
/** Source Demand Routing Protocol internet protocol number.
*/
#define IPPROTO_SDRP 42
 
/** Routing Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Route 43
 
/** Fragment Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Frag 44
 
/** Inter-Domain Routing Protocol internet protocol number.
*/
#define IPPROTO_IDRP 45
 
/** Reservation Protocol internet protocol number.
*/
#define IPPROTO_RSVP 46
 
/** General Routing Encapsulation internet protocol number.
*/
#define IPPROTO_GRE 47
 
/** Dynamic Source Routing Protocol internet protocol number.
*/
#define IPPROTO_DSR 48
 
/** BNA internet protocol number.
*/
#define IPPROTO_BNA 49
 
/** Encap Security Payload internet protocol number.
*/
#define IPPROTO_ESP 50
 
/** Authentication Header internet protocol number.
*/
#define IPPROTO_AH 51
 
/** Integrated Net Layer Security TUBA internet protocol number.
*/
#define IPPROTO_I_NLSP 52
 
/** IP with Encryption internet protocol number.
*/
#define IPPROTO_SWIPE 53
 
/** NBMA Address Resolution Protocol internet protocol number.
*/
#define IPPROTO_NARP 54
 
/** IP Mobility internet protocol number.
*/
#define IPPROTO_MOBILE 55
 
/** Transport Layer Security Protocol
using Kryptonet key management internet protocol number.
*/
#define IPPROTO_TLSP 56
 
/** SKIP internet protocol number.
*/
#define IPPROTO_SKIP 57
 
/** ICMP for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_ICMP 58
 
/** No Next Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_NoNxt 59
 
/** Destination Options for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Opts 60
 
/** Any host internal protocol internet protocol number.
*/
#define IPPROTO_AHIP 61
 
/** CFTP internet protocol number.
*/
#define IPPROTO_CFTP 62
 
/** Any local network internet protocol number.
*/
#define IPPROTO_ALN 63
 
/** SATNET and Backroom EXPAK internet protocol number.
*/
#define IPPROTO_SAT_EXPAK 64
 
/** Kryptolan internet protocol number.
*/
#define IPPROTO_KRYPTOLAN 65
 
/** MIT Remote Virtual Disk Protocol internet protocol number.
*/
#define IPPROTO_RVD 66
 
/** Internet Pluribus Packet Core internet protocol number.
*/
#define IPPROTO_IPPC 67
 
/** Any distributed file system internet protocol number.
*/
#define IPPROTO_ADFS 68
 
/** SATNET Monitoring internet protocol number.
*/
#define IPPROTO_SAT_MON 69
 
/** VISA Protocol internet protocol number.
*/
#define IPPROTO_VISA 70
 
/** Internet Packet Core Utility internet protocol number.
*/
#define IPPROTO_IPCV 71
 
/** Computer Protocol Network Executive internet protocol number.
*/
#define IPPROTO_CPNX 72
 
/** Computer Protocol Heart Beat internet protocol number.
*/
#define IPPROTO_CPHB 73
 
/** Wang Span Network internet protocol number.
*/
#define IPPROTO_WSN 74
 
/** Packet Video Protocol internet protocol number.
*/
#define IPPROTO_PVP 75
 
/** Backroom SATNET Monitoring internet protocol number.
*/
#define IPPROTO_BR_SAT_MON 76
 
/** SUN ND IPPROTOCOL_Temporary internet protocol number.
*/
#define IPPROTO_SUN_ND 77
 
/** WIDEBAND Monitoring internet protocol number.
*/
#define IPPROTO_WB_MON 78
 
/** WIDEBAND EXPAK internet protocol number.
*/
#define IPPROTO_WB_EXPAK 79
 
/** ISO Internet Protocol internet protocol number.
*/
#define IPPROTO_ISO_IP 80
 
/** VMTP internet protocol number.
*/
#define IPPROTO_VMTP 81
 
/** SECURE-VMTP internet protocol number.
*/
#define IPPROTO_SECURE_VMTP 82
 
/** VINES internet protocol number.
*/
#define IPPROTO_VINES 83
 
/** TTP internet protocol number.
*/
#define IPPROTO_TTP 84
 
/** NSFNET-IGP internet protocol number.
*/
#define IPPROTO_NSFNET_IGP 85
 
/** Dissimilar Gateway Protocol internet protocol number.
*/
#define IPPROTO_DGP 86
 
/** TCF internet protocol number.
*/
#define IPPROTO_TCF 87
 
/** EIGRP internet protocol number.
*/
#define IPPROTO_EIGRP 88
 
/** OSPFIGP internet protocol number.
*/
#define IPPROTO_OSPFIGP 89
 
/** Sprite RPC Protocol internet protocol number.
*/
#define IPPROTO_Sprite_RPC 90
 
/** Locus Address Resolution Protocol internet protocol number.
*/
#define IPPROTO_LARP 91
 
/** Multicast Transport Protocol internet protocol number.
*/
#define IPPROTO_MTP 92
 
/** AX.25 Frames internet protocol number.
*/
#define IPPROTO_AX25 93
 
/** IP-within-IP Encapsulation Protocol internet protocol number.
*/
#define IPPROTO_IPIP 94
 
/** Mobile Internetworking Control Pro. internet protocol number.
*/
#define IPPROTO_MICP 95
 
/** Semaphore Communications Sec. Pro. internet protocol number.
*/
#define IPPROTO_SCC_SP 96
 
/** Ethernet-within-IP Encapsulation internet protocol number.
*/
#define IPPROTO_ETHERIP 97
 
/** Encapsulation Header internet protocol number.
*/
#define IPPROTO_ENCAP 98
 
/** Any private encryption scheme internet protocol number.
*/
#define IPPROTO_APES 99
 
/** GMTP internet protocol number.
*/
#define IPPROTO_GMTP 100
 
/** Ipsilon Flow Management Protocol internet protocol number.
*/
#define IPPROTO_IFMP 101
 
/** PNNI over IP internet protocol number.
*/
#define IPPROTO_PNNI 102
 
/** Protocol Independent Multicast internet protocol number.
*/
#define IPPROTO_PIM 103
 
/** ARIS internet protocol number.
*/
#define IPPROTO_ARIS 104
 
/** SCPS internet protocol number.
*/
#define IPPROTO_SCPS 105
 
/** QNX internet protocol number.
*/
#define IPPROTO_QNX 106
 
/** Active Networks internet protocol number.
*/
#define IPPROTO_AN 107
 
/** IP Payload Compression Protocol internet protocol number.
*/
#define IPPROTO_IPComp 108
 
/** Sitara Networks Protocol internet protocol number.
*/
#define IPPROTO_SNP 109
 
/** Compaq Peer Protocol internet protocol number.
*/
#define IPPROTO_Compaq_Peer 110
 
/** IPX in IP internet protocol number.
*/
#define IPPROTO_IPX_in_IP 111
 
/** Virtual Router Redundancy Protocol internet protocol number.
*/
#define IPPROTO_VRRP 112
 
/** PGM Reliable Transport Protocol internet protocol number.
*/
#define IPPROTO_PGM 113
 
/** Any 0-hop protocol internet protocol number.
*/
#define IPPROTO_A0HP 114
 
/** Layer Two Tunneling Protocol internet protocol number.
*/
#define IPPROTO_L2TP 115
 
/** D-II Data Exchange (DDX) internet protocol number.
*/
#define IPPROTO_DDX 116
 
/** Interactive Agent Transfer Protocol internet protocol number.
*/
#define IPPROTO_IATP 117
 
/** Schedule Transfer Protocol internet protocol number.
*/
#define IPPROTO_STP 118
 
/** SpectraLink Radio Protocol internet protocol number.
*/
#define IPPROTO_SRP 119
 
/** UTI internet protocol number.
*/
#define IPPROTO_UTI 120
 
/** Simple Message Protocol internet protocol number.
*/
#define IPPROTO_SMP 121
 
/** SM internet protocol number.
*/
#define IPPROTO_SM 122
 
/** Performance Transparency Protocol internet protocol number.
*/
#define IPPROTO_PTP 123
 
/** ISIS over IPv4 internet protocol number.
*/
#define IPPROTO_ISIS 124
 
/** FIRE internet protocol number.
*/
#define IPPROTO_FIRE 125
 
/** Combat Radio Transport Protocol internet protocol number.
*/
#define IPPROTO_CRTP 126
 
/** Combat Radio User Datagram internet protocol number.
*/
#define IPPROTO_CRUDP 127
 
/** SSCOPMCE internet protocol number.
*/
#define IPPROTO_SSCOPMCE 128
 
/** IPLT internet protocol number.
*/
#define IPPROTO_IPLT 129
 
/** Secure Packet Shield internet protocol number.
*/
#define IPPROTO_SPS 130
 
/** Private IP Encapsulation within IP internet protocol number.
*/
#define IPPROTO_PIPE 131
 
/** Stream Control Transmission Protocol internet protocol number.
*/
#define IPPROTO_SCTP 132
 
/** Fibre Channel internet protocol number.
*/
#define IPPROTO_FC 133
 
/** RSVP-E2E-IGNORE internet protocol number.
*/
#define IPPROTO_RSVP_E2E_IGNORE 134
 
/** Mobility Header internet protocol number.
*/
#define IPPROTO_MH 135
 
/** UDPLite internet protocol number.
*/
#define IPPROTO_UDPLITE 136
 
/** MPLS-in-IP internet protocol number.
*/
#define IPPROTO_MPLS_in_IP 137
 
/** MANET Protocols internet protocol number.
*/
#define IPPROTO_manet 138
 
/** Host Identity Protocol internet protocol number.
*/
#define IPPROTO_HIP 139
 
/** Raw internet protocol number.
*/
#define IPPROTO_RAW 255
 
/** Maximum internet protocol number.
*/
#define IPPROTO_MAX ( IPPROTO_RAW + 1 )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/include/il_interface.h
0,0 → 1,63
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net_il
* @{
*/
 
/** @file
*/
 
#ifndef __NET_IL_INTERFACE_H__
#define __NET_IL_INTERFACE_H__
 
#include <async.h>
 
#include <ipc/services.h>
 
#include "../messages.h"
 
#include "../include/device.h"
 
#include "../structures/packet/packet.h"
#include "../structures/packet/packet_client.h"
 
#include "../il/il_messages.h"
 
static inline int il_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
return generic_device_state_msg( il_phone, NET_IL_DEVICE_STATE, device_id, state );
}
 
inline static int il_received_msg( int il_phone, device_id_t device_id, packet_t packet, services_t target ){
return generic_received_msg( il_phone, NET_IL_RECEIVED, device_id, packet_get_id( packet ), target );
}
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/netif_interface.h
0,0 → 1,59
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NETIF_INTERFACE_H__
#define __NET_NETIF_INTERFACE_H__
 
#include <ipc/services.h>
 
#include "../messages.h"
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
 
#include "device.h"
 
int netif_get_addr( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data );
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io );
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender );
int netif_start_req( int netif_phone, device_id_t device_id );
int netif_stop_req( int netif_phone, device_id_t device_id );
int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/include/ip_interface.h
0,0 → 1,55
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/** @file
*/
 
#ifndef __NET_IP_INTERFACE_H__
#define __NET_IP_INTERFACE_H__
 
#include <async.h>
 
#include <ipc/services.h>
 
#include "../include/device.h"
 
#include "../structures/packet/packet.h"
 
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver );
int ip_device_req( int ip_phone, device_id_t device_id, services_t service );
int ip_send_msg( int ip_phone, device_id_t device_id, packet_t packet, services_t sender );
int ip_connect_module( services_t service );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/net/net_standalone.c
0,0 → 1,123
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*
*/
 
#include <stdio.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../include/ip_interface.h"
 
#include "../structures/measured_strings.h"
#include "../structures/module_map.h"
#include "../structures/packet/packet_server.h"
 
#include "net.h"
 
extern net_globals_t net_globals;
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
if( IS_NET_PACKET_MESSAGE( call )){
return packet_server_message( callid, call, answer, answer_count );
}else{
return net_message( callid, call, answer, answer_count );
}
}
 
int net_initialize( void ){
ERROR_DECLARE;
 
task_id_t task_id;
 
netifs_initialize( & net_globals.netifs );
char_map_initialize( & net_globals.netif_names );
modules_initialize( & net_globals.modules );
measured_strings_initialize( & net_globals.configuration );
 
// run self tests
// ERROR_PROPAGATE( self_test());
 
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service ));
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service ));
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service ));
 
task_id = spawn( "/srv/ip" );
if( ! task_id ) return EINVAL;
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id, ip_connect_module ));
// if( ! spawn( "/srv/udp" )) return EINVAL;
// if( ! spawn( "/srv/tcp" )) return EINVAL;
// if( ! spawn( "/srv/socket" )) return EINVAL;
// not always necesssary
// if( ! spawn( "/srv/arp" )) return EINVAL;
// if( ! spawn( "/srv/rarp" )) return EINVAL;
// if( ! spawn( "/srv/icmp" )) return EINVAL;
return EOK;
}
 
int read_netif_configuration( char * name, netif_ref netif ){
ERROR_DECLARE;
 
if( strncmp( name, "lo", 2 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
}else if( strncmp( name, "ne2k", 4 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
// standalone ethernet
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
}
return EOK;
}
 
/** @}
*/
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net/net_bundle.c
0,0 → 1,155
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*
*/
 
#include <stdio.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../include/ip_interface.h"
 
#include "../structures/measured_strings.h"
#include "../structures/module_map.h"
#include "../structures/packet/packet_server.h"
 
#include "../il/arp/arp_module.h"
#include "../il/ip/ip_module.h"
 
#include "net.h"
 
extern net_globals_t net_globals;
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
if( IS_NET_IL_MESSAGE( call )){
switch( IPC_GET_TARGET( call )){
case SERVICE_IP:
return ip_message( callid, call, answer, answer_count );
default:
return EINVAL;
}
}else if( IS_NET_IP_MESSAGE( call )){
return ip_message( callid, call, answer, answer_count );
}else if( IS_NET_ARP_MESSAGE( call )){
return arp_message( callid, call, answer, answer_count );
/* }else if( IS_NET_RARP_MESSAGE( call )){
return rarp_message( callid, call, answer, answer_count );
}else if( IS_NET_ICMP_MESSAGE( call )){
return icmp_message( callid, call, answer, answer_count );
}else if( IS_NET_UDP_MESSAGE( call )){
return udp_message( callid, call, answer, answer_count );
}else if( IS_NET_TCP_MESSAGE( call )){
return tcp_message( callid, call, answer, answer_count );
}else if( IS_NET_SOCKET_MESSAGE( call )){
return socket_message( callid, call, answer, answer_count );
*/ }else{
if( IS_NET_PACKET_MESSAGE( call )){
return packet_server_message( callid, call, answer, answer_count );
}else{
return net_message( callid, call, answer, answer_count );
}
}
}
 
int net_initialize( void ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
netifs_initialize( & net_globals.netifs );
char_map_initialize( & net_globals.netif_names );
modules_initialize( & net_globals.modules );
measured_strings_initialize( & net_globals.configuration );
 
// run self tests
// ERROR_PROPAGATE( self_test());
 
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service ));
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service ));
 
ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash ));
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id(), ip_connect_module ));
ERROR_PROPAGATE( ip_initialize());
ERROR_PROPAGATE( REGISTER_ME( SERVICE_ARP, & phonehash ));
ERROR_PROPAGATE( arp_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_RARP, & phonehash ));
// ERROR_PROPAGATE( rarp_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_ICMP, & phonehash ));
// ERROR_PROPAGATE( icmp_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_UDP, & phonehash ));
// ERROR_PROPAGATE( udp_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
// ERROR_PROPAGATE( tcp_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_SOCKET, & phonehash ));
// ERROR_PROPAGATE( socket_initialize());
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash ));
// ERROR_PROPAGATE( ethernet_initialize());
return EOK;
}
 
int read_netif_configuration( char * name, netif_ref netif ){
ERROR_DECLARE;
 
if( strncmp( name, "lo", 2 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
}else if( strncmp( name, "ne2k", 4 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
// ethernet bundled in dp8390
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", DP8390_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
}
return EOK;
}
 
/** @}
*/
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net/net_remote.c
0,0 → 1,68
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*/
 
#include <ipc/services.h>
 
#include <malloc.h>
 
#include "../messages.h"
#include "../modules.h"
 
#include "../include/device.h"
#include "../include/net_interface.h"
 
#include "../structures/measured_strings.h"
 
//#include "net_messages.h"
 
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data ){
return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, device_id, 0, * configuration, count, configuration, data );
}
 
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){
return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, * configuration, count, configuration, data );
}
 
void net_free_settings( measured_string_ref settings, char * data ){
if( settings ) free( settings );
if( data ) free( data );
}
 
int net_connect_module( services_t service ){
return connect_to_service( SERVICE_NETWORKING );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/net/net.c
0,0 → 1,386
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*/
 
#include <async.h>
#include <ctype.h>
#include <ddi.h>
#include <errno.h>
#include <malloc.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../err.h"
#include "../messages.h"
#include "../modules.h"
//#include "../self_test.h"
 
#include "../structures/char_map.h"
#include "../structures/generic_char_map.h"
#include "../structures/measured_strings.h"
#include "../structures/module_map.h"
#include "../structures/packet/packet.h"
 
#include "../il/il_messages.h"
#include "../include/device.h"
#include "../include/netif_interface.h"
#include "../include/nil_interface.h"
#include "../include/net_interface.h"
#include "../include/ip_interface.h"
 
#include "net.h"
 
#define NAME "Networking"
 
void module_print_name( void );
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
int module_start( async_client_conn_t client_connection );
//int parse_line( measured_strings_ref configuration, char * line );
int read_configuration( void );
int start_device( netif_ref netif );
int startup( void );
device_id_t generate_new_device_id( void );
int net_get_conf( measured_strings_ref device_conf, measured_string_ref configuration, int count, char ** data );
 
net_globals_t net_globals;
 
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
 
GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t )
 
void module_print_name( void ){
printf( "%s", NAME );
}
 
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( net_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_NETWORKING, & phonehash ))){
pm_destroy();
return ERROR_CODE;
}
 
async_manager();
 
pm_destroy();
return EOK;
}
 
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data ){
netif_ref netif;
 
if( !( configuration && ( count > 0 ))) return EINVAL;
netif = netifs_find( & net_globals.netifs, device_id );
if( netif ){
return net_get_conf( & netif->configuration, * configuration, count, data );
}else{
return net_get_conf( NULL, * configuration, count, data );
}
}
 
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){
if( !( configuration && ( count > 0 ))) return EINVAL;
return net_get_conf( NULL, * configuration, count, data );
}
 
int net_get_conf( measured_strings_ref device_conf, measured_string_ref configuration, int count, char ** data ){
measured_string_ref setting;
int index;
 
if( data ) * data = NULL;
for( index = 0; index < count; ++ index ){
setting = measured_strings_find( device_conf, configuration[ index ].value, 0 );
if( ! setting ){
setting = measured_strings_find( & net_globals.configuration, configuration[ index ].value, 0 );
}
if( setting ){
configuration[ index ].length = setting->length;
configuration[ index ].value = setting->value;
}else{
configuration[ index ].length = 0;
configuration[ index ].value = NULL;
}
}
return EOK;
}
 
void net_free_settings( measured_string_ref settings, char * data ){
}
 
int net_connect_module( services_t service ){
return EOK;
}
 
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
measured_string_ref strings;
char * data;
 
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_NET_DEVICE:
// TODO configure, register
printf( "Networking: new netif %d\n", IPC_GET_DEVICE( call ));
return EOK;
case NET_NET_GET_DEVICE_CONF:
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
net_get_device_conf_req( 0, IPC_GET_DEVICE( call ), & strings, IPC_GET_COUNT( call ), NULL );
// strings should not contain received data anymore
free( data );
ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
free( strings );
return ERROR_CODE;
case NET_NET_GET_CONF:
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
net_get_conf_req( 0, & strings, IPC_GET_COUNT( call ), NULL );
// strings should not contain received data anymore
free( data );
ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
free( strings );
return ERROR_CODE;
case NET_NET_STARTUP:
return startup();
}
return ENOTSUP;
}
 
/*
int parse_line( measured_strings_ref configuration, char * line ){
ERROR_DECLARE;
 
measured_string_ref setting;
char * name;
char * value;
 
// from the beginning
name = line;
// skip spaces
while( isspace( * name )) ++ name;
// remember the name start
value = name;
// skip the name
while( isalnum( * value ) || ( * value == '_' )){
// make uppercase
// * value = toupper( * value );
++ value;
}
if( * value == '=' ){
// terminate the name
* value = '\0';
}else{
// terminate the name
* value = '\0';
// skip until '='
++ value;
while(( * value ) && ( * value != '=' )) ++ value;
// not found?
if( * value != '=' ) return EINVAL;
}
++ value;
// skip spaces
while( isspace( * value )) ++ value;
// create a bulk measured string till the end
setting = measured_string_create_bulk( value, -1 );
if( ! setting ) return ENOMEM;
// add the configuration setting
if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
return EOK;
}
*/
 
int add_configuration( measured_strings_ref configuration, const char * name, const char * value ){
ERROR_DECLARE;
 
measured_string_ref setting;
 
setting = measured_string_create_bulk( value, 0 );
if( ! setting ) return ENOMEM;
// add the configuration setting
if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
return EOK;
}
 
device_id_t generate_new_device_id( void ){
return device_assign_devno();
}
 
int read_configuration( void ){
ERROR_DECLARE;
 
// read general configuration
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IPV", "4" ));
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "MTU", "1500" ));
return EOK;
}
 
int start_device( netif_ref netif ){
ERROR_DECLARE;
 
measured_string_ref setting;
services_t internet_service;
int irq;
int io;
int mtu;
 
// mandatory netif
setting = measured_strings_find( & netif->configuration, CONF_NETIF, 0 );
netif->driver = get_running_module( & net_globals.modules, setting->value );
if( ! netif->driver ){
printf( "Failed to start the network interface driver %s\n", setting->value );
return EINVAL;
}
// optional network interface layer
setting = measured_strings_find( & netif->configuration, CONF_NIL, 0 );
if( setting ){
netif->nil = get_running_module( & net_globals.modules, setting->value );
if( ! netif->nil ){
printf( "Failed to start the network interface layer %s\n", setting->value );
return EINVAL;
}
}else{
netif->nil = NULL;
}
// mandatory internet layer
setting = measured_strings_find( & netif->configuration, CONF_IL, 0 );
netif->il = get_running_module( & net_globals.modules, setting->value );
if( ! netif->il ){
printf( "Failed to start the internet layer %s\n", setting->value );
return EINVAL;
}
// end of the static loopback initialization
// startup the loopback interface
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( netif_probe_req( netif->driver->phone, netif->id, irq, io ));
if( netif->nil ){
setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 );
if( ! setting ){
setting = measured_strings_find( & net_globals.configuration, CONF_MTU, 0 );
}
mtu = setting ? strtol( setting->value, NULL, 10 ) : 0;
ERROR_PROPAGATE( nil_device_req( netif->nil->phone, netif->id, mtu, netif->driver->service ));
internet_service = netif->nil->service;
}else{
internet_service = netif->driver->service;
}
switch( netif->il->service ){
case SERVICE_IP:
ERROR_PROPAGATE( ip_device_req( netif->il->phone, netif->id, internet_service ));
break;
default:
return ENOENT;
}
ERROR_PROPAGATE( netif_start_req( netif->driver->phone, netif->id ));
return EOK;
}
 
int startup( void ){
ERROR_DECLARE;
 
char * conf_files[] = { "lo", "ne2k" };
int count = sizeof( conf_files ) / sizeof( char * );
int index;
netif_ref netif;
int i;
measured_string_ref setting;
 
// TODO dynamic configuration
ERROR_PROPAGATE( read_configuration());
 
for( i = 0; i < count; ++ i ){
netif = ( netif_ref ) malloc( sizeof( netif_t ));
if( ! netif ) return ENOMEM;
 
netif->id = generate_new_device_id();
if( ! netif->id ) return EXDEV;
ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration ));
// read configuration files
if( ERROR_OCCURRED( read_netif_configuration( conf_files[ i ], netif ))){
measured_strings_destroy( & netif->configuration );
free( netif );
return ERROR_CODE;
}
// mandatory name
setting = measured_strings_find( & netif->configuration, CONF_NAME, 0 );
if( ! setting ){
printf( "The name is missing\n" );
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
netif->name = setting->value;
// add to the netifs map
index = netifs_add( & net_globals.netifs, netif->id, netif );
if( index < 0 ){
measured_strings_destroy( & netif->configuration );
free( netif );
return index;
}
// add to the netif names map
if( ERROR_OCCURRED( char_map_add( & net_globals.netif_names, netif->name, 0, index ))
// start network interfaces and needed modules
|| ERROR_OCCURRED( start_device( netif ))){
measured_strings_destroy( & netif->configuration );
netifs_exclude_index( & net_globals.netifs, index );
return ERROR_CODE;
}
// increment modules' usage
++ netif->driver->usage;
if( netif->nil ) ++ netif->nil->usage;
++ netif->il->usage;
printf( "New network interface started:\n\tname\t= %s\n\tid\t= %d\n\tdriver\t= %s\n\tnil\t= %s\n\til\t= %s\n", netif->name, netif->id, netif->driver->name, netif->nil ? netif->nil->name : NULL, netif->il->name );
}
return EOK;
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net/net.h
0,0 → 1,125
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
* Networking subsystem compilation configuration.
*/
 
#ifndef __NET_NET_H__
#define __NET_NET_H__
 
#include <ipc/ipc.h>
 
#include "../include/device.h"
 
#include "../structures/char_map.h"
#include "../structures/generic_char_map.h"
#include "../structures/measured_strings.h"
#include "../structures/module_map.h"
#include "../structures/packet/packet.h"
 
#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 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"
 
typedef struct netif netif_t;
typedef netif_t * netif_ref;
 
typedef struct net_globals net_globals_t;
 
DEVICE_MAP_DECLARE( netifs, netif_t )
 
GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t )
 
/** A present network interface device.
*/
struct netif{
/** A system-unique network interface identifier.
*/
device_id_t id;
/** A serving network interface driver module index.
*/
module_ref driver;
/** A serving link layer module index.
*/
module_ref nil;
/** A serving internet layer module index.
*/
module_ref il;
/** A system-unique network interface name.
*/
char * name;
/** Configuration.
*/
measured_strings_t configuration;
};
 
/** A net module global variables.
*/
struct net_globals{
/** Present network interfaces.
*/
netifs_t netifs;
/** Network interface structure indices by names.
*/
char_map_t netif_names;
/** Available modules.
*/
modules_t modules;
/** Global configuration.
*/
measured_strings_t configuration;
};
 
int add_configuration( measured_strings_ref configuration, const char * name, const char * value );
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int net_initialize( void );
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int read_netif_configuration( char * name, netif_ref netif );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net/Makefile
0,0 → 1,70
#
# Copyright (c) 2009 Lukas Mejdrech
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
NAME = net
 
NET_BASE = ../
STRUCTURES = $(NET_BASE)structures/
 
include $(NET_BASE)../../../Makefile.config
 
## Sources
#
 
OUTPUT = $(NAME)
SOURCES = \
$(NAME).c \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)char_map.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)module_map.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet_server.c \
$(NET_BASE)netif/netif_remote.c
# $(NET_BASE)self_test.c
 
ifeq ($(NETWORKING), module)
 
SOURCES += $(NAME)_bundle.c \
$(NET_BASE)il/arp/arp.c \
$(NET_BASE)il/ip/ip.c \
$(NET_BASE)sockaddr.c
# $(NET_BASE)tl/tcp/tcp.c
 
else
 
SOURCES += $(NAME)_standalone.c \
$(NET_BASE)il/arp/arp_remote.c \
$(NET_BASE)il/ip/ip_remote.c \
# $(NET_BASE)tl/tcp/tcp_remote.c
 
endif
 
include $(NET_BASE)Makefile.module
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/net/start/netstart.c
0,0 → 1,113
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
* Starts the net subsystem.
* Performs self test if configured so.
* @see configuration.h
*/
 
#include <async.h>
#include <stdio.h>
#include <task.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../../err.h"
#include "../../messages.h"
#include "../../modules.h"
#include "../../self_test.h"
 
/** Networking startup module name.
*/
#define NAME "Networking startup"
 
/** Module entry point.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the net module cannot be started.
* @returns Other error codes as defined for the self_test() function.
* @returns Other error codes as defined for the NET_NET_STARTUP message.
*/
int main( int argc, char * argv[] );
 
/** Starts the module.
* @param fname The module absolute name. Input parameter.
* @returns The started module task identifier.
* @returns Other error codes as defined for the task_spawn() function.
*/
task_id_t spawn( char * fname );
 
int main( int argc, char * argv[] ){
ERROR_DECLARE;
 
int net_phone;
 
printf( "Task %d - ", task_get_id());
printf( "%s\n", NAME );
// run self tests
ERROR_PROPAGATE( self_test());
// start net service
if( ! spawn( "/srv/net" )){
printf( "Could not spawn net\n" );
return EINVAL;
}
// start net
net_phone = connect_to_service( SERVICE_NETWORKING );
if( ERROR_OCCURRED( ipc_call_sync_0_0( net_phone, NET_NET_STARTUP ))){
printf( "ERROR %d\n", ERROR_CODE );
return ERROR_CODE;
}
printf( "OK\n" );
 
return EOK;
}
 
task_id_t spawn( char * fname ){
char * argv[ 2 ];
task_id_t res;
 
// printf( "Spawning %s\n", fname );
argv[ 0 ] = fname;
argv[ 1 ] = NULL;
res = task_spawn( fname, argv );
if( res != 0 ){
/* Success */
usleep( 50000 );
}
return res;
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net/start/Makefile
0,0 → 1,48
#
# Copyright (c) 2009 Lukas Mejdrech
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
NAME = netstart
 
NET_BASE = ../../
STRUCTURES = $(NET_BASE)structures/
 
include ../../../../../Makefile.config
 
## Sources
#
 
OUTPUT = $(NAME)
SOURCES = \
$(NAME).c \
$(NET_BASE)modules.c \
$(NET_BASE)self_test.c \
$(STRUCTURES)char_map.c \
$(STRUCTURES)measured_strings.c \
$(NET_BASE)crc.c
 
include $(NET_BASE)Makefile.module
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/net/start
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/srv/net/net
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/srv/net/messages.h
50,8 → 50,8
#define NET_NET_COUNT 9
#define NET_NIL_COUNT 7
#define NET_ETH_COUNT 0
#define NET_IL_COUNT 3
#define NET_IP_COUNT 2
#define NET_IL_COUNT 4
#define NET_IP_COUNT 0
#define NET_ARP_COUNT 4
#define NET_RARP_COUNT 0
#define NET_ICMP_COUNT 0
60,7 → 60,7
#define NET_PACKET_COUNT 5
#define NET_SOCKET_COUNT 0
 
#define NET_FIRST 2000
#define NET_FIRST 2000
 
#define NET_NETIF_FIRST NET_FIRST
#define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT )
74,9 → 74,9
#define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT )
 
#define NET_IL_FIRST ( NET_ETH_LAST + 0 )
#define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT )
#define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT )
#define NET_IP_FIRST ( NET_IL_LAST + 0 )
#define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT )
#define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT )
 
#define NET_ARP_FIRST ( NET_IP_LAST + 0 )
#define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT )
95,9 → 95,9
#define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 )
#define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT )
 
#define NET_LAST NET_PACKET_LAST
#define NET_LAST NET_PACKET_LAST
 
#define NET_COUNT ( NET_LAST - NET_FIRST )
#define NET_COUNT ( NET_LAST - NET_FIRST )
 
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
 
121,7 → 121,7
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call )
 
#define IPC_GET_COUNT( call ) ( int ) IPC_GET_ARG2( * call )
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call )
 
/** Returns the device driver service message parameter.
156,22 → 156,6
NET_NET_STOP,
/* ( device_id ) ipc_data_read( stats ) */
NET_NET_STATS,
/* ( device_id, nil_service ) */
NET_IL_DEVICE = NET_IL_FIRST,
/* ( device_id, state ) */
NET_IL_DEVICE_STATE,
/* ( device_id ), packet_send */
NET_IL_RECEIVED,
/* ( device_id ), measured_strings_send( address ) */
// NET_IL_MY_ADDR,
NET_IP_ECHO = NET_IP_FIRST,
/* ( packet_id ) */
NET_IP_SEND,
NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
NET_PACKET_CREATE_4,
NET_PACKET_GET,
NET_PACKET_GET_SIZE,
NET_PACKET_RELEASE
} net_messages;
 
static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){
180,7 → 164,7
int string;
 
if( !( address && data )) return EBADMEM;
message_id = async_send_1( phone, message, device_id, NULL );
message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL );
string = measured_strings_return( phone, address, data, 1 );
async_wait_for( message_id, & result );
if(( string == EOK ) && ( result != EOK )){
187,27 → 171,48
free( * address );
free( * data );
}
return result;
return ( int ) result;
}
 
static inline void generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){
async_msg_3( phone, message, device_id, packet_id, sender );
static inline int generic_translate_req( int phone, int message, device_id_t device_id, services_t service, measured_string_ref configuration, size_t count, measured_string_ref * translation, char ** data ){
aid_t message_id;
ipcarg_t result;
int string;
 
if( !( configuration && ( count > 0 ))) return EINVAL;
if( !( translation && data )) return EBADMEM;
message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL );
measured_strings_send( phone, configuration, count );
string = measured_strings_return( phone, translation, data, count );
async_wait_for( message_id, & result );
if(( string == EOK ) && ( result != EOK )){
free( * translation );
free( * data );
}
return ( int ) result;
}
 
static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){
async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender );
return EOK;
}
 
static inline int generic_packet_size_req( int phone, int message, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
return async_req_1_4( phone, message, device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
}
 
static inline void generic_device_state_msg( int phone, int message, device_id_t device_id, int state ){
async_msg_2( phone, message, device_id, state );
static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state ){
async_msg_2( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state );
return EOK;
}
 
static inline void generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){
async_msg_3( phone, message, device_id, packet_id, target );
static inline int generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){
async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target );
return EOK;
}
 
static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){
return async_req_3_0( phone, message, device_id, arg2, service );
return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service );
}
 
#endif
/branches/network/uspace/srv/net/modules.h
33,6 → 33,9
/** @file
*/
 
#ifndef __NET_MODULES_H__
#define __NET_MODULES_H__
#include <async.h>
 
#include <ipc/ipc.h>
47,8 → 50,12
 
#define REGISTER_ME( me, phonehash ) ipc_connect_to_me( PHONE_NS, ( me ), 0, 0, ( phonehash ))
 
int connect_to_service( services_t need );
typedef int connect_module_t( services_t need );
 
connect_module_t connect_to_service;
int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver );
 
#endif
 
/** @}
*/
/branches/network/uspace/srv/net/Makefile.module
40,7 → 40,7
 
LIBS = $(LIBC_PREFIX)/libc.a
 
DEFS += $(NET_DEFS) -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
DEFS += $(NET_DEFS)
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
DISASMS := $(addsuffix .disasm,$(basename $(OUTPUT)))
55,17 → 55,14
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(addsuffix .map,$(basename $(SOURCES))) $(DISASMS) Makefile.depend
-rm -f $(OUTPUT) $(OUTPUT).map $(addsuffix .map,$(basename $(SOURCES))) $(DISASMS) Makefile.depend
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
 
$(OUTPUT): freshen $(OBJECTS) $(LIBS)
$(OUTPUT): $(OBJECTS) $(LIBS)
$(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $@.map
 
freshen:
-rm -f $(addsuffix .o,$(basename $(REBUILD)))
 
disasm: $(DISASMS)
 
%.disasm: $@
/branches/network/uspace/srv/net/il/il_messages.h
0,0 → 1,59
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net_il
* @{
*/
 
/** @file
*/
 
#ifndef __NET_IL_MESSAGES_H__
#define __NET_IL_MESSAGES_H__
 
#include <ipc/ipc.h>
 
typedef enum{
/* ( device_id, nil_service ) */
NET_IL_DEVICE = NET_IL_FIRST,
/* ( device_id, state ) */
NET_IL_DEVICE_STATE,
/* ( device_id ), packet_send */
NET_IL_RECEIVED,
/* ( device_id ), measured_strings_send( address ) */
// NET_IL_MY_ADDR,
/* ( packet_id ) */
NET_IL_SEND,
} il_messages;
 
#define IL_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp_wrappers.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp_messages.h
0,0 → 1,61
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup arp
* @{
*/
 
/** @file
*/
 
#ifndef __NET_ARP_MESSAGES__
#define __NET_ARP_MESSAGES__
 
#include <ipc/ipc.h>
 
#include "../../messages.h"
 
typedef enum{
/* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */
NET_ARP_DEVICE = NET_ARP_FIRST,
/* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */
NET_ARP_TRANSLATE,
/* ( device_id ) */
NET_ARP_CLEAR_DEVICE,
/* () */
NET_ARP_CLEAN_CACHE,
} arp_messages;
 
/** Returns the protocol service message parameter.
*/
#define ARP_GET_NETIF( call ) ( services_t ) IPC_GET_ARG2( * call )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp.c
40,6 → 40,7
#include <mem.h>
#include <rwlock.h>
#include <stdio.h>
#include <task.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
50,8 → 51,8
 
#include "../../include/byteorder.h"
#include "../../include/device.h"
#include "../../include/arp_messages.h"
#include "../../include/nil_messages.h"
#include "../../include/arp_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/protocol_map.h"
 
#include "../../structures/measured_strings.h"
58,16 → 59,33
#include "../../structures/packet/packet.h"
#include "../../structures/packet/packet_client.h"
 
#include "../il_messages.h"
 
#include "arp.h"
#include "arp_header.h"
#include "arp_oc.h"
#include "arp_module.h"
#include "arp_wrappers.h"
#include "arp_messages.h"
 
/** ARP global data.
*/
arp_globals_t arp_globals;
 
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address );
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data );
 
/** Clears the whole cache.
* @returns EOK on success.
*/
int arp_clean_cache_req( int arp_phone );
 
/** Clears the device specific data from the cache.
* @param device_id The device identifier. Input parameter.
* @returns EOK on success.
* @returns ENOENT if the device is not found in the cache.
*/
int arp_clear_device_req( int arp_phone, device_id_t device_id );
 
/** Creates new protocol specific data.
* @param proto Protocol specific data. Output parameter.
* @param service Protocol module service. Input parameter.
134,7 → 152,11
 
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
 
int arp_clear_device_wrapper( device_id_t device_id ){
int arp_task_get_id( void ){
return task_get_id();
}
 
int arp_clear_device_req( int arp_phone, device_id_t device_id ){
arp_device_ref device;
 
rwlock_write_lock( & arp_globals.lock );
144,12 → 166,12
return ENOENT;
}
clear_device( device );
printf( "\nDevice %d cleared", device_id );
printf( "Device %d cleared\n", device_id );
rwlock_write_unlock( & arp_globals.lock );
return EOK;
}
 
int arp_clean_cache_wrapper( void ){
int arp_clean_cache_req( int arp_phone ){
int count;
arp_device_ref device;
 
164,11 → 186,11
}
arp_cache_clear( & arp_globals.cache );
rwlock_write_unlock( & arp_globals.lock );
printf( "\nCache cleaned" );
printf( "Cache cleaned\n" );
return EOK;
}
 
int arp_device_wrapper( device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
ERROR_DECLARE;
 
measured_string_ref tmp;
181,7 → 203,7
return ERROR_CODE;
}
 
int arp_translate_wrapper( device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){
measured_string_ref tmp;
 
rwlock_read_lock( & arp_globals.lock );
238,7 → 260,7
device = arp_cache_find( & arp_globals.cache, device_id );
if( device ){
if( device->service != service ){
printf( "\nDevice %d already exists", device->device_id );
printf( "Device %d already exists\n", device->device_id );
rwlock_write_unlock( & arp_globals.lock );
return EEXIST;
}
260,7 → 282,7
return index;
}
}
printf( "\nCache of the existing device %d cleaned", device->device_id );
printf( "Cache of the existing device %d cleaned\n", device->device_id );
}else{
index = hardware_map( service );
if( ! index ) return ENOENT;
327,7 → 349,7
free( device );
return ERROR_CODE;
}
printf( "\nNew device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d", device->device_id, device->hardware, device->service );
printf( "New device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d\n", device->device_id, device->hardware, device->service );
}
rwlock_write_unlock( & arp_globals.lock );
return EOK;
351,7 → 373,7
// ARP packet content size = header + ( address + translation ) * 2
length = 8 + ( CONVERT_SIZE( char, uint8_t, proto->addr->length ) + CONVERT_SIZE( char, uint8_t, device->addr->length )) * 2;
if( length > device->content ) return NULL;
packet = packet_get_4( arp_globals.networking_phone, device->addr_len, device->prefix, length, device->suffix );
packet = packet_get_4( arp_globals.net_phone, device->addr_len, device->prefix, length, device->suffix );
if( ! packet ) return NULL;
header = ( arp_header_ref ) packet_suffix( packet, length );
header->hardware = htons( device->hardware );
428,7 → 450,7
packet_set_addr( packet, src_hw, des_hw, header->hardware_length );
nil_send_msg( device->phone, device_id, packet, SERVICE_ARP );
}else{
pq_release( arp_globals.networking_phone, packet_get_id( packet ));
pq_release( arp_globals.net_phone, packet_get_id( packet ));
}
}
return EOK;
449,6 → 471,10
arp_protos_clear( & device->protos );
}
 
int arp_connect_module( services_t service ){
return EOK;
}
 
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
456,7 → 482,7
measured_string_ref translation;
char * data;
 
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_ARP_FIRST );
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST );
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
463,7 → 489,7
return EOK;
case NET_ARP_DEVICE:
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), ARP_GET_PROTO( call ), address ))){
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), ARP_GET_NETIF( call ), address ))){
free( address );
free( data );
}
471,7 → 497,7
case NET_ARP_TRANSLATE:
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
rwlock_read_lock( & arp_globals.lock );
translation = arp_translate_message( IPC_GET_DEVICE( call ), ARP_GET_PROTO( call ), address );
translation = arp_translate_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), address );
free( address );
free( data );
if( ! translation ){
482,9 → 508,9
rwlock_read_unlock( & arp_globals.lock );
return ERROR_CODE;
case NET_ARP_CLEAR_DEVICE:
return arp_clear_device_wrapper( IPC_GET_DEVICE( call ));
return arp_clear_device_req( 0, IPC_GET_DEVICE( call ));
case NET_ARP_CLEAN_CACHE:
return arp_clean_cache_wrapper();
return arp_clean_cache_req( 0 );
}
return ENOTSUP;
}
501,7 → 527,7
ipc_answer_0( iid, EOK );
break;
case NET_IL_RECEIVED:
if( ! ERROR_OCCURRED( packet_translate( arp_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){
rwlock_read_lock( & arp_globals.lock );
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( icall ), packet );
rwlock_read_unlock( & arp_globals.lock );
/branches/network/uspace/srv/net/il/arp/arp.h
160,7 → 160,7
struct arp_globals{
/** Networking module phone.
*/
int networking_phone;
int net_phone;
/** Safety lock.
*/
rwlock_t lock;
/branches/network/uspace/srv/net/il/arp/arp_module.c
46,6 → 46,8
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "arp.h"
58,7 → 60,7
/** Prints the module name.
* @see NAME
*/
void arp_print_name( void );
void module_print_name( void );
 
/** Starts the ARP 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.
67,23 → 69,24
* @returns Other error codes as defined for the arp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
*/
int arp_start_module( async_client_conn_t client_connection );
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 );
 
/** ARP module global data.
*/
extern arp_globals_t arp_globals;
 
void arp_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
int arp_start_module( async_client_conn_t client_connection ){
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
arp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
arp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( arp_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ARP, & phonehash ))){
97,5 → 100,9
return EOK;
}
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
return arp_message( callid, call, answer, answer_count );
}
 
/** @}
*/
/branches/network/uspace/srv/net/il/arp/Makefile
43,8 → 43,9
$(STRUCTURES)char_map.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c
$(STRUCTURES)/packet/packet_client.c \
$(STRUCTURES)/packet/packet_remote.c \
$(NET_BASE)nil/nil_remote.c \
$(NET_BASE)net/net_remote.c
 
NET_DEFS += -D ARP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/il/arp/arp_remote.c
0,0 → 1,83
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup arp
* @{
*/
 
/** @file
*/
 
#include <async.h>
#include <errno.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../../messages.h"
#include "../../modules.h"
 
#include "../../include/device.h"
#include "../../include/arp_interface.h"
 
#include "../../structures/measured_strings.h"
 
#include "arp_messages.h"
 
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
aid_t message_id;
ipcarg_t result;
 
message_id = async_send_3( arp_phone, NET_ARP_DEVICE, device_id, protocol, netif, NULL );
measured_strings_send( arp_phone, address, 1 );
async_wait_for( message_id, & result );
return result;
}
 
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){
return generic_translate_req( arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data );
}
 
int arp_clear_device_req( int arp_phone, device_id_t device_id ){
return async_req_1_0( arp_phone, NET_ARP_CLEAR_DEVICE, device_id );
}
 
int arp_clean_cache_req( int arp_phone ){
return async_req_0_0( arp_phone, NET_ARP_CLEAN_CACHE );
}
 
int arp_connect_module( services_t service ){
return connect_to_service( SERVICE_ARP );
}
 
int arp_task_get_id( void ){
return 0;
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip_remote.c
0,0 → 1,67
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/** @file
*/
 
#include <ipc/services.h>
 
#include <ipc/services.h>
 
#include "../../messages.h"
#include "../../modules.h"
 
#include "../../include/device.h"
#include "../../include/ip_interface.h"
 
#include "../../structures/packet/packet_client.h"
 
#include "../il_messages.h"
 
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver ){
return bind_service( service, 0, me, 0, receiver );
}
 
int ip_device_req( int ip_phone, device_id_t device_id, services_t service ){
return generic_device_req( ip_phone, NET_IL_DEVICE, device_id, 0, service );
}
 
int ip_send_msg( int ip_phone, device_id_t device_id, packet_t packet, services_t sender ){
return generic_send_msg( ip_phone, NET_IL_SEND, -1, packet_get_id( packet ), sender );
}
 
int ip_connect_module( services_t service ){
return connect_to_service( SERVICE_IP );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip.c
44,17 → 44,23
#include "../../messages.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
#include "../../include/sockaddr.h"
#include "../../include/socket.h"
#include "../../include/device.h"
#include "../../include/arp_messages.h"
#include "../../include/nil_messages.h"
#include "../../include/arp_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
#include "../../include/ip_interface.h"
#include "../../structures/measured_strings.h"
#include "../../structures/module_map.h"
#include "../../structures/packet/packet_client.h"
 
#include "../../nil/nil_messages.h"
 
#include "../il_messages.h"
 
#include "ip.h"
#include "ip_messages.h"
#include "ip_module.h"
 
#define DEFAULT_IPV 4
62,10 → 68,6
#define ARP_NAME "arp"
#define ARP_FILENAME "/srv/arp"
 
#define IPC_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call )
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call )
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call )
 
ip_globals_t ip_globals;
 
DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t )
72,9 → 74,9
 
INT_MAP_IMPLEMENT( ip_protos, ip_proto_t )
 
int ip_register_message( int protocol, int phone );
int ip_state_message( device_id_t device_id, device_state_t state );
void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall );
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state );
int ip_register( int il_phone, int protocol, int phone );
 
/** Initializes the module.
*/
84,92 → 86,60
ERROR_PROPAGATE( ip_netifs_initialize( & ip_globals.netifs ));
ERROR_PROPAGATE( ip_protos_initialize( & ip_globals.protos ));
ERROR_PROPAGATE( modules_initialize( & ip_globals.modules ));
ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, 0 ));
ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, arp_task_get_id(), arp_connect_module ));
return EOK;
}
 
int ip_echo_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t * answer1, ipcarg_t * answer2, ipcarg_t * answer3, ipcarg_t * answer4, ipcarg_t * answer5 ){
if( answer1 ) * answer1 = arg1;
if( answer2 ) * answer2 = arg2;
if( answer3 ) * answer3 = arg3;
if( answer4 ) * answer4 = arg4;
if( answer5 ) * answer5 = arg5;
return EOK;
}
 
int ip_device_message( device_id_t device_id, services_t service ){
int ip_device_req( int il_phone, device_id_t device_id, services_t service ){
ERROR_DECLARE;
 
ip_netif_ref ip_netif;
aid_t message;
ipc_call_t answer;
measured_string_t configuration[ 9 ] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "NETMASK", 7 }, { "GATEWAY", 7 }, { "BROADCAST", 9 }, { "DNS1", 4 }, { "DNS2", 4 }, { "ARP", 3 }};
int count = 9;
measured_string_ref settings;
char * data;
ipcarg_t result;
int index;
ip_netif_ref ip_netif;
measured_string_t names[ 9 ] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "NETMASK", 7 }, { "GATEWAY", 7 }, { "BROADCAST", 9 }, { "DNS1", 4 }, { "DNS2", 4 }, { "ARP", 3 }};
measured_string_ref configuration;
int count = 9;
char * data;
int index;
 
configuration = & names[ 0 ];
ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t ));
if( ! ip_netif ) return ENOMEM;
ip_netif->device_id = device_id;
// get configuration
// TODO mapping
message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer );
// send names and get settings
if( ERROR_OCCURRED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
|| ERROR_OCCURRED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
async_wait_for( message, NULL );
free( ip_netif );
return ERROR_CODE;
}
async_wait_for( message, & result );
if( ERROR_OCCURRED( result )){
if( settings ){
free( settings );
free( data );
};
free( ip_netif );
return ERROR_CODE;
}
if( settings ){
if( settings[ 0 ].value ){
ip_netif->ipv = strtol( settings[ 0 ].value, NULL, 0 );
ERROR_PROPAGATE( net_get_device_conf_req( ip_globals.net_phone, ip_netif->device_id, & configuration, count, & data ));
if( configuration ){
if( configuration[ 0 ].value ){
ip_netif->ipv = strtol( configuration[ 0 ].value, NULL, 0 );
}else{
ip_netif->ipv = DEFAULT_IPV;
}
ip_netif->dhcp = ! strncmp( settings[ 1 ].value, "dhcp", 4 );
ip_netif->dhcp = ! strncmp( configuration[ 1 ].value, "dhcp", 4 );
if( ip_netif->dhcp ){
// TODO dhcp
free( settings );
free( data );
net_free_settings( configuration, data );
free( ip_netif );
return ENOTSUP;
}else if( ip_netif->ipv == 4 ){
if( ERROR_OCCURRED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
|| ERROR_OCCURRED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
|| ( inet_pton( AF_INET, settings[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
|| ( inet_pton( AF_INET, settings[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
|| ( inet_pton( AF_INET, settings[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
|| ( inet_pton( AF_INET, settings[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){
free( settings );
free( data );
if( ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
|| ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
|| ( inet_pton( AF_INET, configuration[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){
net_free_settings( configuration, data );
free( ip_netif );
return EINVAL;
}
}else{
// TODO ipv6
free( settings );
free( data );
net_free_settings( configuration, data );
free( ip_netif );
return ENOTSUP;
}
if( settings[ 8 ].value ){
ip_netif->arp = get_running_module( & ip_globals.modules, settings[ 8 ].value );
if( configuration[ 8 ].value ){
ip_netif->arp = get_running_module( & ip_globals.modules, configuration[ 8 ].value );
if( ! ip_netif->arp ){
printf( "\nFailed to start the arp %s", settings[ 8 ].value );
free( settings );
free( data );
printf( "Failed to start the arp %s\n", configuration[ 8 ].value );
net_free_settings( configuration, data );
free( ip_netif );
return EINVAL;
}
176,12 → 146,11
}else{
ip_netif->arp = NULL;
}
free( settings );
free( data );
net_free_settings( configuration, data );
}
ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
if( ip_netif->phone < 0 ){
printf( "\nFailed to contact the nil service %d", service );
printf( "Failed to contact the nil service %d\n", service );
free( ip_netif );
return ip_netif->phone;
}
200,23 → 169,23
}
if( ip_netif->arp ) ++ ip_netif->arp->usage;
// 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( "New device registered:\n\tid\t= %d\n\tphone\t= %d\n\tIPV\t= %d\n", ip_netif->device_id, ip_netif->phone, ip_netif->ipv );
printf( "\tconfiguration\t= %s\n", ip_netif->dhcp ? "dhcp" : "static" );
// TODO ipv6 addresses
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( "\taddress\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN );
printf( "\n\tnetmask\t= %s", data );
printf( "\tnetmask\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN );
printf( "\n\tgateway\t= %s", data );
printf( "\tgateway\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN );
printf( "\n\tbroadcast\t= %s", data );
printf( "\tbroadcast\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
printf( "\n\tdns1\t= %s", data );
printf( "\tdns1\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
printf( "\n\tdns2\t= %s", data );
printf( "\tdns2\t= %s\n", data );
free( data );
}
return EOK;
254,20 → 223,22
switch( IPC_GET_METHOD( call )){
case NET_IL_DEVICE_STATE:
case NET_NIL_DEVICE_STATE:
result = ip_state_message( IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
result = ip_device_state_msg( 0, IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
ipc_answer_0( callid, result );
break;
// TODO packer received
case NET_IL_RECEIVED:
case NET_NIL_RECEIVED:
if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
//result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( & call )))){
//result = il_receive_msg( 0, IPC_GET_DEVICE( call ), packet );
}
ipc_answer_0( callid, result );
break;
}
}
}
 
int ip_state_message( device_id_t device_id, device_state_t state ){
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
ERROR_DECLARE;
 
ip_netif_ref netif;
279,12 → 250,12
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ) return ENOENT;
// TODO state
printf( "\nip - device %d changed state to %d\n", device_id, state );
printf( "ip - device %d changed state to %d\n\n", device_id, state );
if( netif->arp ){
address.value = ( char * ) & netif->gateway;
address.length = CONVERT_SIZE( in_addr_t, char, 1 );
ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ));
printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
printf( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
free( translation );
free( data );
}
291,7 → 262,16
return EOK;
}
 
int ip_register_message( int protocol, int phone ){
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver ){
//TODO receive function
return EOK;
}
 
int ip_connect_module( services_t service ){
return EOK;
}
 
int ip_register( int il_phone, int protocol, int phone ){
ip_proto_ref proto;
int index;
 
304,14 → 284,14
free( proto );
return index;
}
printf( "\nNew protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d", proto->protocol, proto->phone );
printf( "New protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d\n", proto->protocol, proto->phone );
return EOK;
}
 
int ip_send_message( device_id_t device_id, packet_t packet ){
int ip_send_msg( int il_phone, device_id_t device_id, packet_t packet, services_t target ){
// TODO send packet
printf( "Packet to send via %d: %s", device_id, packet_get_data( packet ));
pq_release( ip_globals.networking_phone, packet_get_id( packet ));
printf( "Packet to send via %d: %s\n", device_id, packet_get_data( packet ));
pq_release( ip_globals.net_phone, packet_get_id( packet ));
return EOK;
}
 
324,16 → 304,13
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_IP_ECHO:
* answer_count = 5;
return ip_echo_message( IPC_GET_ARG1( * call ), IPC_GET_ARG2( * call ), IPC_GET_ARG3( * call ), IPC_GET_ARG4( * call ), IPC_GET_ARG5( * call ), & IPC_GET_ARG1( * answer ), & IPC_GET_ARG2( * answer ), & IPC_GET_ARG3( * answer ), & IPC_GET_ARG4( * answer ), & IPC_GET_ARG5( * answer ) );
case NET_IL_DEVICE:
return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
return ip_device_req( 0, IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
case IPC_M_CONNECT_TO_ME:
return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call ));
case NET_IP_SEND:
ERROR_PROPAGATE( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )));
return ip_send_message( IPC_GET_DEVICE( call ), packet );
return ip_register( 0, IL_GET_PROTO( call ), IPC_GET_PHONE( call ));
case NET_IL_SEND:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 );
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/il/ip/Makefile
31,6 → 31,9
NET_BASE = ../../
STRUCTURES = $(NET_BASE)structures/
 
## Sources
#
 
OUTPUT = $(NAME)
SOURCES = \
$(NAME)_module.c \
41,9 → 44,11
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)module_map.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c \
$(NET_BASE)sockaddr.c
$(STRUCTURES)/packet/packet_client.c \
$(NET_BASE)sockaddr.c \
$(STRUCTURES)/packet/packet_remote.c \
$(NET_BASE)il/arp/arp_remote.c \
$(NET_BASE)nil/nil_remote.c \
$(NET_BASE)net/net_remote.c
 
NET_DEFS += -D IP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/il/ip/ip.h
77,7 → 77,7
};
 
struct ip_globals{
int networking_phone;
int net_phone;
ip_netifs_t netifs;
ip_protos_t protos;
modules_t modules;
/branches/network/uspace/srv/net/il/ip/ip_module.c
42,6 → 42,8
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "ip.h"
49,22 → 51,23
 
#define NAME "IP protocol"
 
void ip_print_name( void );
int ip_start_module( async_client_conn_t client_connection );
void module_print_name( void );
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 );
 
extern ip_globals_t ip_globals;
 
void ip_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
int ip_start_module( async_client_conn_t client_connection ){
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
ip_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
ip_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( ip_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_IP, & phonehash ))){
78,5 → 81,9
return EOK;
}
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
return ip_message( callid, call, answer, answer_count );
}
 
/** @}
*/
/branches/network/uspace/srv/net/netif/netif_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_wrappers.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_module.h
0,0 → 1,57
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
#ifndef __NET_NETIF_MODULE_H__
#define __NET_NETIF_MODULE_H__
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
 
#include "../include/device.h"
 
int netif_initialize( void );
int netif_probe_auto_message( void );
int netif_probe_message( device_id_t device_id, int irq, int io );
int netif_send_message( device_id_t device_id, packet_t packet, services_t sender );
int netif_start_message( device_ref device );
int netif_stop_message( device_ref device );
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 );
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/netif/netif_nil_bundle.c
0,0 → 1,70
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../structures/packet/packet.h"
 
#include "../nil/nil_module.h"
 
#include "netif.h"
 
extern netif_globals_t netif_globals;
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
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 ){
if( IS_NET_NIL_MESSAGE( call ) || ( IPC_GET_METHOD( * call ) == IPC_M_CONNECT_TO_ME )){
return nil_message( callid, call, answer, answer_count );
}else{
return netif_message( callid, call, answer, answer_count );
}
}
 
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ERROR_PROPAGATE( netif_init_module( client_connection ));
if( ERROR_OCCURRED( nil_initialize( netif_globals.net_phone ))){
pm_destroy();
return ERROR_CODE;
}
return netif_run_module();
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_remote.c
0,0 → 1,71
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
#include <ipc/services.h>
 
#include "../modules.h"
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
#include "../structures/packet/packet_client.h"
 
#include "../include/device.h"
#include "../include/netif_interface.h"
 
#include "netif_messages.h"
 
int netif_get_addr( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data ){
return generic_get_addr( netif_phone, NET_NETIF_GET_ADDR, device_id, address, data );
}
 
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){
return async_req_3_0( netif_phone, NET_NETIF_PROBE, device_id, irq, io );
}
 
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender ){
return generic_send_msg( netif_phone, NET_NETIF_SEND, device_id, packet_get_id( packet ), sender );
}
 
int netif_start_req( int netif_phone, device_id_t device_id ){
return async_req_1_0( netif_phone, NET_NETIF_START, device_id );
}
 
int netif_stop_req( int netif_phone, device_id_t device_id ){
return async_req_1_0( netif_phone, NET_NETIF_STOP, device_id );
}
 
int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver ){
return bind_service( service, device_id, me, 0, receiver );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/netif/netif_messages.h
0,0 → 1,70
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NETIF_MESSAGES_H__
#define __NET_NETIF_MESSAGES_H__
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
typedef enum {
/* ( device_id, irq, io ) */
NET_NETIF_PROBE = NET_NETIF_FIRST,
/* () not supported, should ask networking for a name and register device */
NET_NETIF_PROBE_AUTO,
/* ( device_id, packet_id ) */
NET_NETIF_SEND,
/* ( device_id ) */
NET_NETIF_START,
/* ( device_id ), ipc_data_read( stats ) */
NET_NETIF_STATS,
/* ( device_id ) */
NET_NETIF_STOP,
/* */
NET_NETIF_SET_ADDR,
/* */
NET_NETIF_GET_ADDR,
} netif_messages;
 
#define NETIF_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call )
 
#define NETIF_GET_IO( call ) ( int ) IPC_GET_ARG3( * call )
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif.c
50,28 → 50,20
#include "../structures/measured_strings.h"
 
#include "../include/device.h"
#include "../include/netif_messages.h"
#include "../include/nil_messages.h"
#include "../include/netif_interface.h"
#include "../include/nil_interface.h"
 
#include "netif.h"
#include "netif_interface.h"
#include "netif_wrappers.h"
#include "netif_messages.h"
#include "netif_module.h"
 
#if NIL_BUNDLE
 
#include "../nil/nil_module.h"
 
#endif
 
extern netif_globals_t netif_globals;
 
DEVICE_MAP_IMPLEMENT( device_map, device_t )
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int netif_start_module( async_client_conn_t client_connection );
int register_message( device_id_t device_id, int phone );
 
int netif_probe_wrapper( device_id_t device_id, int irq, int io ){
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){
int result;
 
rwlock_write_lock( & netif_globals.lock );
80,7 → 72,7
return result;
}
 
int netif_send_wrapper( device_id_t device_id, packet_t packet, services_t sender ){
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender ){
int result;
 
rwlock_write_lock( & netif_globals.lock );
89,7 → 81,7
return result;
}
 
int netif_start_wrapper( device_id_t device_id ){
int netif_start_req( int netif_phone, device_id_t device_id ){
ERROR_DECLARE;
 
device_ref device;
113,7 → 105,7
return result;
}
 
int netif_stop_wrapper( device_id_t device_id ){
int netif_stop_req( int netif_phone, device_id_t device_id ){
ERROR_DECLARE;
 
device_ref device;
137,7 → 129,7
return result;
}
 
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address, char ** data ){
int netif_get_addr( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data ){
ERROR_DECLARE;
 
measured_string_t translation;
149,9 → 141,14
ERROR_CODE = ( * address ) ? EOK : ENOMEM;
}
rwlock_read_unlock( & netif_globals.lock );
* data = ( ** address ).value;
return ERROR_CODE;
}
 
int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver ){
return EOK;
}
 
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 );
172,7 → 169,7
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->nil_phone > 0 ) return ELIMIT;
device->nil_phone = phone;
printf( "\nNew receiver of the device %d registered:\n\tphone\t= %d", device->device_id, device->nil_phone );
printf( "New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone );
return EOK;
}
 
184,12 → 181,7
packet_t packet;
measured_string_t address;
 
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_NETIF_FIRST );
#if NIL_BUNDLE
if( IS_NET_NIL_MESSAGE( call )){
return nil_message( callid, call, answer, answer_count );
}
#endif
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NETIF_FIRST );
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
200,22 → 192,18
rwlock_write_unlock( & netif_globals.lock );
return ERROR_CODE;
case NET_NETIF_PROBE:
return netif_probe_wrapper( IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call ));
return netif_probe_req( 0, IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call ));
case IPC_M_CONNECT_TO_ME:
#if NIL_BUNDLE
return nil_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call ));
#else
rwlock_write_lock( & netif_globals.lock );
ERROR_CODE = register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call ));
rwlock_write_unlock( & netif_globals.lock );
return ERROR_CODE;
#endif
case NET_NETIF_SEND:
case NET_NIL_SEND:
ERROR_PROPAGATE( packet_translate( netif_globals.networking_phone, & packet, IPC_GET_PACKET( call )));
return netif_send_wrapper( IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call ));
ERROR_PROPAGATE( packet_translate( netif_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return netif_send_msg( 0, IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call ));
case NET_NETIF_START:
return netif_start_wrapper( IPC_GET_DEVICE( call ));
return netif_start_req( 0, IPC_GET_DEVICE( call ));
case NET_NETIF_STATS:
rwlock_read_lock( & netif_globals.lock );
if( ! ERROR_OCCURRED( ipc_data_read_receive( & callid, & length ))){
230,7 → 218,7
rwlock_read_unlock( & netif_globals.lock );
return ERROR_CODE;
case NET_NETIF_STOP:
return netif_stop_wrapper( IPC_GET_DEVICE( call ));
return netif_stop_req( 0, IPC_GET_DEVICE( call ));
case NET_NETIF_GET_ADDR:
case NET_NIL_ADDR:
rwlock_read_lock( & netif_globals.lock );
243,11 → 231,11
return netif_specific_message( callid, call, answer, answer_count );
}
 
int netif_start_module( async_client_conn_t client_connection ){
int netif_init_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
async_set_client_connection( client_connection );
netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
netif_globals.net_phone = connect_to_service( SERVICE_NETWORKING );
device_map_initialize( & netif_globals.device_map );
ERROR_PROPAGATE( pm_init());
rwlock_initialize( & netif_globals.lock );
255,13 → 243,10
pm_destroy();
return ERROR_CODE;
}
#if NIL_BUNDLE
if( ERROR_OCCURRED( nil_initialize( netif_globals.networking_phone ))){
pm_destroy();
return ERROR_CODE;
}
#endif
return EOK;
}
 
int netif_run_module( void ){
async_manager();
 
pm_destroy();
269,11 → 254,11
}
 
void netif_pq_release( packet_id_t packet_id ){
pq_release( netif_globals.networking_phone, packet_id );
pq_release( netif_globals.net_phone, packet_id );
}
 
packet_t netif_packet_get_1( size_t content ){
return packet_get_1( netif_globals.networking_phone, content );
return packet_get_1( netif_globals.net_phone, content );
}
 
/** @}
/branches/network/uspace/srv/net/netif/dp8390/dp8390.c
1447,7 → 1447,7
dep->de_locmem = (char *)-dep->de_ramsize; /* trap errors */
return;
}else{
printf( "map_hw_buffer: no buffer!" );
printf( "map_hw_buffer: no buffer!\n" );
}
 
// size = dep->de_ramsize + PAGE_SIZE; /* Add PAGE_SIZE for
/branches/network/uspace/srv/net/netif/dp8390/Makefile
37,27 → 37,28
#
 
OUTPUT = dp8390
REBUILD = $(OUTPUT)_module.c \
../$(NAME).c
SOURCES = \
$(OUTPUT).c \
$(REBUILD) \
$(OUTPUT)_module.c \
../$(NAME).c \
ne2000.c \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet.c
$(STRUCTURES)packet/packet_remote.c
 
NET_DEFS += -D NETIF_BUNDLE=1
 
ifeq ($(NETWORKING), module)
 
SOURCES += $(NET_BASE)crc.c
SOURCES += ../$(NAME)_nil_bundle.c \
$(NET_BASE)crc.c \
$(NET_BASE)nil/eth/eth.c
 
REBUILD += $(NET_BASE)nil/eth/eth.c
else
 
NET_DEFS += -D NIL_BUNDLE=1
SOURCES += ../$(NAME)_standalone.c \
$(NET_BASE)nil/nil_remote.c
 
endif
 
/branches/network/uspace/srv/net/netif/dp8390/dp8390_module.c
49,10 → 49,10
#include "../../structures/measured_strings.h"
 
#include "../../include/device.h"
#include "../../include/nil_messages.h"
#include "../../include/nil_interface.h"
 
#include "../netif.h"
#include "../netif_interface.h"
#include "../netif_module.h"
 
#include "dp8390.h"
#include "dp8390_drv.h"
89,7 → 89,7
 
netif_globals_t netif_globals;
 
void netif_print_name( void );
void module_print_name( void );
 
void irq_handler( ipc_callid_t iid, ipc_call_t * call );
int change_state( device_ref device, device_state_t state );
123,7 → 123,7
return EOK;
}
 
void netif_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
149,7 → 149,7
int phone;
 
device_id = IRQ_GET_DEVICE( call );
// printf( "\ndevice %d - irq %x", device_id, IPC_GET_ISR( call ));
// printf( "device %d - irq %x\n", device_id, IPC_GET_ISR( call ));
rwlock_write_lock( & netif_globals.lock );
if( find_device( device_id, & device ) != EOK ){
rwlock_write_unlock( & netif_globals.lock );
156,7 → 156,7
return;
}
dep = ( dpeth_t * ) device->specific;
// printf( "\ndev %d, irq %x\n", device->device_id, IPC_GET_ISR( call ));
// printf( "dev %d, irq %x\n\n", device->device_id, IPC_GET_ISR( call ));
if ( dep->de_mode != DEM_ENABLED){
// continue;
rwlock_write_unlock( & netif_globals.lock );
199,7 → 199,6
device_ref device;
dpeth_t * dep;
 
printf( "\n" );
device = ( device_ref ) malloc( sizeof( device_t ));
if( ! device ) return ENOMEM;
dep = ( dpeth_t * ) malloc( sizeof( dpeth_t ));
239,7 → 238,7
 
uint8_t * data;
data = packet_get_data( packet );
printf( "\nSending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] );
printf( "Sending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] );
 
ERROR_PROPAGATE( find_device( device_id, & device ));
dep = ( dpeth_t * ) device->specific;
287,7 → 286,7
 
int change_state( device_ref device, device_state_t state ){
device->state = state;
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
return state;
}
 
/branches/network/uspace/srv/net/netif/lo/lo.c
48,10 → 48,11
#include "../../structures/packet/packet_client.h"
 
#include "../../include/device.h"
#include "../../include/nil_messages.h"
#include "../../include/nil_interface.h"
#include "../../include/net_interface.h"
 
#include "../netif.h"
#include "../netif_interface.h"
#include "../netif_module.h"
 
#define DEFAULT_MTU 1500
 
63,12 → 64,12
netif_globals_t netif_globals;
 
static struct lo_globals{
int mtu;
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 );
void netif_print_name( void );
void module_print_name( void );
 
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
//TODO nil send message
96,7 → 97,7
static int change_state_message( device_ref device, device_state_t state ){
if( device->state != state ){
device->state = state;
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
return state;
}
return EOK;
136,7 → 137,7
return REGISTER_ME( SERVICE_LO, & phonehash );
}
 
void netif_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
146,7 → 147,7
device_ref device;
 
ERROR_PROPAGATE( create( arg1, & device ));
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
ipc_call_sync_3_3( netif_globals.net_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
*/ return ENOTSUP;
}
 
153,44 → 154,26
int netif_probe_message( device_id_t device_id, int irq, int io ){
ERROR_DECLARE;
 
device_ref device;
aid_t message;
ipc_call_t answer;
measured_string_t configuration[ 1 ] = {{ "MTU", 3 }};
int count = 1;
measured_string_ref settings;
char * data;
ipcarg_t result;
device_ref device;
measured_string_t names[ 1 ] = {{ "MTU", 3 }};
measured_string_ref configuration;
int count = 1;
char * data;
 
configuration = & names[ 0 ];
// create a new device
ERROR_PROPAGATE( create( device_id, & device ));
// get configuration
message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer );
// send names and get settings
if( ERROR_OCCURRED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
|| ERROR_OCCURRED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
async_wait_for( message, NULL );
return ERROR_CODE;
}
// end request
async_wait_for( message, & result );
if( ERROR_OCCURRED( result )){
if( settings ){
free( settings );
free( data );
}
return ERROR_CODE;
}
ERROR_PROPAGATE( net_get_device_conf_req( netif_globals.net_phone, device->device_id, & configuration, count, & data ));
// MTU is the first one
if( settings && ( settings[ 0 ].value )){
lo_globals.mtu = strtoul( settings[ 0 ].value, NULL, 0 );
free( settings );
free( data );
if( configuration && configuration[ 0 ].value ){
lo_globals.mtu = strtoul( configuration[ 0 ].value, NULL, 0 );
net_free_settings( configuration, data );
}else{
lo_globals.mtu = DEFAULT_MTU;
}
// print the settings
printf("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
printf("New device registered:\n\tid\t= %d\n\tMTU\t= %d\n", device->device_id, lo_globals.mtu );
return EOK;
}
 
/branches/network/uspace/srv/net/netif/lo/Makefile
35,16 → 35,17
#
 
OUTPUT = lo
REBUILD = ../$(NAME).c
SOURCES = \
$(OUTPUT).c \
$(REBUILD) \
../$(NAME).c \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet.c
$(STRUCTURES)packet/packet_remote.c \
$(NET_BASE)nil/nil_remote.c \
../$(NAME)_standalone.c \
$(NET_BASE)net/net_remote.c
 
NET_DEFS += -D NETIF_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/netif/netif.h
37,10 → 37,17
#ifndef __NET_NETIF_H__
#define __NET_NETIF_H__
 
#include <async.h>
#include <rwlock.h>
 
#include <ipc/ipc.h>
 
#include "../err.h"
 
#include "../include/device.h"
 
#include "../structures/packet/packet.h"
 
/** Network interface module skeleton global data.
*/
typedef struct netif_globals netif_globals_t;
83,7 → 90,7
struct netif_globals{
/** Networking module phone.
*/
int networking_phone;
int net_phone;
/** Device map.
*/
device_map_t device_map;
115,6 → 122,10
*/
packet_t netif_packet_get_1( size_t content );
 
int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int netif_init_module( async_client_conn_t client_connection );
int netif_run_module( void );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/netif/netif_standalone.c
0,0 → 1,58
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup netif
* @{
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
 
#include "netif.h"
 
extern netif_globals_t netif_globals;
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
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 ){
return netif_message( callid, call, answer, answer_count );
}
 
int module_start( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ERROR_PROPAGATE( netif_init_module( client_connection ));
return netif_run_module();
}
 
 
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/module.c
101,10 → 101,11
int main( int argc, char * argv[] ){
ERROR_DECLARE;
 
printf("\nTask %d - ", task_get_id());
printf("Task %d - ", task_get_id());
module_print_name();
printf( "\n" );
if( ERROR_OCCURRED( module_start( client_connection ))){
printf( " - ERROR %i", ERROR_CODE );
printf( " - ERROR %i\n", ERROR_CODE );
return ERROR_CODE;
}
return EOK;
/branches/network/uspace/srv/net/Makefile
31,13 → 31,13
DIRS = \
netif/lo \
netif/dp8390 \
networking \
networking/startup
nil/eth \
net \
net/start
 
DIRS_MODULAR = il/ip \
tl/tcp \
il/arp \
nil/eth \
# il/rarp \
# il/icmp \
# tl/udp \
/branches/network/uspace/srv/net/err.h
39,6 → 39,12
 
#include <errno.h>
 
#ifdef CONFIG_DEBUG
 
#include <stdio.h>
 
#endif
 
/** An actual stored error code.
*/
#define ERROR_CODE error_check_return_value
58,9 → 64,17
/** Checks if an error occurred and immediately exits the actual function returning the error code.
* @param value The value to be checked. May be a function call. Input parameter.
*/
#ifdef CONFIG_DEBUG
 
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURRED( value )){ printf( "error at %s:%d %d\n", __FILE__, __LINE__, ERROR_CODE ); return ERROR_CODE; }
 
#else
 
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURRED( value )) return ERROR_CODE
 
#endif
 
#endif
 
/** @}
*/
/branches/network/HelenOS.config
459,6 → 459,6
 
% Networking architecture
@ "modular" Modular
#@ "module" One module
@ "module" One module
! [PLATFORM=ia32] NETWORKING (choice)
 
/branches/network/boot/arch/ia32/Makefile.inc
46,10 → 46,11
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/net/networking/net \
$(USPACEDIR)/srv/net/networking/startup/netstart \
$(USPACEDIR)/srv/net/net/net \
$(USPACEDIR)/srv/net/net/start/netstart \
$(USPACEDIR)/srv/net/netif/lo/lo \
$(USPACEDIR)/srv/net/netif/dp8390/dp8390
$(USPACEDIR)/srv/net/netif/dp8390/dp8390 \
$(USPACEDIR)/srv/net/nil/eth/eth
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
62,7 → 63,6
RD_SRVS += $(USPACEDIR)/srv/net/il/ip/ip \
$(USPACEDIR)/srv/net/tl/tcp/tcp \
$(USPACEDIR)/srv/net/il/arp/arp \
$(USPACEDIR)/srv/net/nil/eth/eth
# $(USPACEDIR)/srv/net/il/rarp/rarp \
# $(USPACEDIR)/srv/net/il/icmp/icmp \
# $(USPACEDIR)/srv/net/tl/udp/udp \