Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4307 → Rev 4300

/branches/network/uspace/srv/net/net/net_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/net/net.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net/net.h
File deleted
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net/start/netstart.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net/start/Makefile
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/net/start
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net/Makefile
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/net/net_standalone.c
File deleted
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net/net_bundle.c
File deleted
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/net
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/structures/measured_strings.h
38,8 → 38,6
#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
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_client.c
50,6 → 50,18
#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;
123,5 → 135,68
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,13 → 48,9
#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
67,6 → 63,28
*/
#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{
91,6 → 109,12
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.
102,18 → 126,8
* @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.
145,24 → 159,6
*/
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;
 
195,22 → 191,16
IPC_SET_ARG1( * answer, packet->length );
return EOK;
case NET_PACKET_RELEASE:
return packet_release_wrapper( IPC_GET_ID( call ));
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 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/packet/packet_header.h
37,8 → 37,6
#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/module_map.c
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup netif
* @{
*/
 
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, 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 ){
ERROR_DECLARE;
 
module_ref tmp_module;
61,7 → 61,6
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;
81,7 → 80,7
if( ! module->task_id ) return NULL;
}
if( ! module->phone ){
module->phone = module->connect_module( module->service );
module->phone = connect_to_service( module->service );
}
return module;
}
/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 net
/** @addtogroup netif
* @{
*/
 
41,8 → 41,6
 
#include <ipc/services.h>
 
#include "../modules.h"
 
#include "generic_char_map.h"
 
typedef struct module_struct module_t;
57,10 → 55,9
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, 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 );
module_ref get_running_module( modules_ref modules, char * name );
task_id_t spawn( char * fname );
 
/branches/network/uspace/srv/net/include/nil_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/include/ip_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/il_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/net_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/include/netif_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/include/ip_protocols.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/include/arp_interface.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/include/nil_messages.h
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_nil
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NIL_MESSAGES_H__
#define __NET_NIL_MESSAGES_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 "device.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;
 
#ifdef NIL_BUNDLE
 
#include "../nil/nil_wrappers.h"
 
/** 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 )
 
#define nil_device_state_msg( nil_phone, device_id, state ) \
nil_device_state_wrapper( device_id, state )
 
#define nil_received_msg( nil_phone, device_id, packet, target ) \
( void ) nil_receive_wrapper( device_id, packet )
 
#else
 
#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_state_msg( nil_phone, device_id, state ) \
generic_device_state_msg( nil_phone, NET_NIL_DEVICE_STATE, device_id, state )
 
#define nil_received_msg( nil_phone, device_id, packet, target ) \
generic_received_msg( nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id( packet ), target )
 
#define nil_device_req( nil_phone, device_id, mtu, netif_service ) \
generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
 
#endif
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/arp_messages.h
0,0 → 1,132
/*
* 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_H__
#define __NET_ARP_MESSAGES_H__
 
#include <async.h>
#include <errno.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../structures/measured_strings.h"
 
#include "device.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;
 
static inline int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address );
static inline 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 );
static inline int arp_clear_device_req( int arp_phone, device_id_t device_id );
static inline int arp_clean_cache_req( int arp_phone );
 
#if ARP_BUNDLE
 
#include "../il/arp/arp_wrappers.h"
 
/** Returns the protocol service message parameter.
*/
#define ARP_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call )
 
static inline int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
return arp_device_wrapper( device_id, netif, protocol, address );
}
 
static inline 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 arp_translate_wrapper( device_id, protocol, address, translation, data );
}
 
static inline int arp_clear_device_req( int arp_phone, device_id_t device_id ){
return arp_clear_device_wrapper( device_id );
}
 
static inline int arp_clean_cache_req( int arp_phone ){
return arp_clean_cache_wrapper();
}
 
#else
 
static inline 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;
}
 
static inline 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 ){
aid_t message_id;
ipcarg_t result;
int string;
 
if( !( address && data )) return EBADMEM;
message_id = async_send_2( arp_phone, NET_ARP_TRANSLATE, device_id, protocol, NULL );
measured_strings_send( arp_phone, address, 1 );
string = measured_strings_return( arp_phone, translation, data, 1 );
async_wait_for( message_id, & result );
if(( string == EOK ) && ( result != EOK )){
free( * translation );
free( * data );
}
return result;
}
 
static inline 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 );
}
 
static inline int arp_clean_cache_req( int arp_phone ){
return async_req_0_0( arp_phone, NET_ARP_CLEAN_CACHE );
}
 
#endif
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/netif_messages.h
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 netif
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_NETIF_MESSAGES_H__
#define __NET_NETIF_MESSAGES_H__
 
#include <async.h>
#include <errno.h>
#include <malloc.h>
 
#include <ipc/ipc.h>
 
#include "../messages.h"
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
 
#include "device.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;
 
#ifdef NETIF_BUNDLE
 
#include "../netif/netif_wrappers.h"
 
#define NETIF_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call )
 
#define NETIF_GET_IO( call ) ( int ) IPC_GET_ARG3( * call )
 
#define netif_get_addr( netif_phone, device_id, address, data ) \
netif_get_addr_wrapper( device_id, address, data )
 
static inline int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){
return netif_probe_wrapper( device_id, irq, io );
}
 
#define netif_send_msg( netif_phone, device_id, packet, sender ) \
netif_send_wrapper( device_id, packet, sender )
 
static inline int netif_start_req( int netif_phone, device_id_t device_id ){
return netif_start_wrapper( device_id );
}
 
static inline int netif_stop_req( int netif_phone, device_id_t device_id ){
return netif_stop_wrapper( device_id );
}
 
#else
 
#define netif_get_addr( netif_phone, device_id, address, data ) \
generic_get_addr( netif_phone, NET_NETIF_GET_ADDR, device_id, address, data )
 
static inline 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 );
}
 
#define netif_send_msg( netif_phone, device_id, packet, sender ) \
generic_send_msg( netif_phone, NET_NETIF_SEND, device_id, packet_get_id( packet ), sender )
 
static inline int netif_start_req( int netif_phone, device_id_t device_id ){
return async_req_1_0( netif_phone, NET_NETIF_START, device_id );
}
 
static inline int netif_stop_req( int netif_phone, device_id_t device_id ){
return async_req_1_0( netif_phone, NET_NETIF_STOP, device_id );
}
 
#endif
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/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 net
* @{
*/
 
/** @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
/branches/network/uspace/srv/net/networking/networking.c
0,0 → 1,575
/*
* 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 "../structures/packet/packet_server.h"
 
#include "../il/ip/ip_messages.h"
#include "../include/device.h"
#include "../include/netif_messages.h"
#include "../include/nil_messages.h"
/*
#if IP_BUNDLE
 
#include "../ip/ip_module.h"
 
#endif
 
#if TCP_BUNDLE
 
#include "../tcp/tcp_module.h"
 
#endif
*/
#define NAME "Networking"
 
#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"
 
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
#define IPC_GET_COUNT( call ) ( int ) IPC_GET_ARG2( * call )
 
typedef struct netif netif_t;
typedef netif_t * netif_ref;
 
typedef struct networking_globals networking_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 networking module global variables.
*/
struct networking_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;
};
 
void networking_print_name( void );
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
int networking_start_module( async_client_conn_t client_connection );
int networking_initialize( void );
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
//int parse_line( measured_strings_ref configuration, char * line );
int add_configuration( measured_strings_ref configuration, const char * name, const char * value );
int read_configuration( void );
int read_netif_configuration( char * name, netif_ref netif );
int start_device( netif_ref netif );
int startup( void );
device_id_t generate_new_device_id( void );
 
static networking_globals_t networking_globals;
 
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
 
GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t )
 
void networking_print_name( void ){
printf( "%s", NAME );
}
 
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
/*#ifdef NETWORKING_module
//TODO map to *_message
if( IS_NET_IL_MESSAGE( call ) || 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_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){
return ethernet_message( callid, call, answer, answer_count );
*//* }else{
#endif
*/ if( IS_NET_PACKET_MESSAGE( call )){
return packet_server_message( callid, call, answer, answer_count );
}else{
return net_message( callid, call, answer, answer_count );
}
/*#ifdef NETWORKING_module
}
#endif
*/
}
 
int networking_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( networking_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_NETWORKING, & phonehash ))){
pm_destroy();
return ERROR_CODE;
}
 
async_manager();
 
pm_destroy();
return EOK;
}
 
int networking_initialize( void ){
ERROR_DECLARE;
 
task_id_t task_id;
 
netifs_initialize( & networking_globals.netifs );
char_map_initialize( & networking_globals.netif_names );
modules_initialize( & networking_globals.modules );
measured_strings_initialize( & networking_globals.configuration );
 
// run self tests
// ERROR_PROPAGATE( self_test());
 
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0 ));
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0 ));
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0 ));
 
//#ifdef NETWORKING_modular
task_id = spawn( "/srv/ip" );
if( ! task_id ) return EINVAL;
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id ));
// if( ! spawn( "/srv/udp" )) return EINVAL;
// if( ! spawn( "/srv/tcp" )) return EINVAL;
// if( ! spawn( "/srv/socket" )) return EINVAL;
// not always necesssary
// if( ! spawn( "/srv/arp" )) return EINVAL;
// if( ! spawn( "/srv/rarp" )) return EINVAL;
// if( ! spawn( "/srv/icmp" )) return EINVAL;
/*
#else
#ifdef NETWORKING_module
ipcarg_t phonehash;
 
ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash ));
ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id()));
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());
#endif
#endif
*/
return EOK;
}
 
//TODO as ip.c
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;
int index;
measured_string_ref setting;
measured_strings_ref configuration;
netif_ref netif;
 
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_NET_DEVICE:
// TODO configure, register
printf( "\nNetworking: new netif %d", IPC_GET_DEVICE( call ));
return EOK;
case NET_NET_GET_DEVICE_CONF:
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
netif = netifs_find( & networking_globals.netifs, IPC_GET_DEVICE( call ));
if( netif ){
configuration = & netif->configuration;
}else{
configuration = NULL;
}
for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
setting = measured_strings_find( configuration, strings[ index ].value, 0 );
if( ! setting ){
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
}
if( setting ){
strings[ index ].length = setting->length;
strings[ index ].value = setting->value;
}else{
strings[ index ].length = 0;
strings[ index ].value = 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:
// arg1 = count
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
if( setting ){
strings[ index ].length = setting->length;
strings[ index ].value = setting->value;
}else{
strings[ index ].length = 0;
strings[ index ].value = 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( & networking_globals.configuration, "IPV", "4" ));
ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "MTU", "1500" ));
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 ));
#ifdef NETWORKING_module
// ethernet bundled in dp8390
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", DP8390_NAME ));
#else
// standalone ethernet
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ));
#endif
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;
}
 
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( & networking_globals.modules, setting->value );
if( ! netif->driver ){
printf( "\nFailed to start the network interface driver %s", setting->value );
return EINVAL;
}
// optional network interface layer
setting = measured_strings_find( & netif->configuration, CONF_NIL, 0 );
if( setting ){
netif->nil = get_running_module( & networking_globals.modules, setting->value );
if( ! netif->nil ){
printf( "\nFailed to start the network interface layer %s", 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( & networking_globals.modules, setting->value );
if( ! netif->il ){
printf( "\nFailed to start the internet layer %s", 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( & networking_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;
}
// TODO IL_BUNDLE
ERROR_PROPAGATE( async_req_3_0( netif->il->phone, NET_IL_DEVICE, netif->id, 0, internet_service ));
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( "\nThe name is missing" );
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
netif->name = setting->value;
// add to the netifs map
index = netifs_add( & networking_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( & networking_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( & networking_globals.netifs, index );
return ERROR_CODE;
}
// increment modules' usage
++ netif->driver->usage;
if( netif->nil ) ++ netif->nil->usage;
++ netif->il->usage;
printf( "\nNew network interface started:\n\tname\t= %s\n\tid\t= %d\n\tdriver\t= %s\n\tnil\t= %s\n\til\t= %s", netif->name, netif->id, netif->driver->name, netif->nil ? netif->nil->name : NULL, netif->il->name );
}
return EOK;
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/Makefile
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.
#
 
NAME = networking
 
NET_BASE = ../
STRUCTURES = $(NET_BASE)structures/
 
include $(NET_BASE)../../../Makefile.config
 
## Sources
#
 
OUTPUT = net
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_server.c
# $(NET_BASE)self_test.c
 
ifeq ($(NETWORKING), module)
 
SOURCES += $(NET_BASE)il/arp/arp.c \
$(NET_BASE)il/ip/ip.c \
$(NET_BASE)tl/tcp/tcp.c
 
NET_DEFS += -D ARP_BUNDLE=1 -D IP_BUNDLE=1 -D TCP_BUNDLE=1
 
endif
 
include $(NET_BASE)Makefile.module
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/networking/startup/networking_startup.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 networking 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 networking 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 networking_phone;
 
printf( "\nTask %d - ", task_get_id());
printf( "%s", NAME );
// run self tests
ERROR_PROPAGATE( self_test());
// start networking service
if( ! spawn( "/srv/net" )){
printf( "\nCould not spawn networking" );
return EINVAL;
}
// start networking
networking_phone = connect_to_service( SERVICE_NETWORKING );
if( ERROR_OCCURRED( ipc_call_sync_0_0( networking_phone, NET_NET_STARTUP ))){
printf( "\nERROR %d\n", ERROR_CODE );
return ERROR_CODE;
}
printf( "\nOK\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
/branches/network/uspace/srv/net/networking/startup/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 = networking_startup
 
NET_BASE = ../../
STRUCTURES = $(NET_BASE)structures/
 
include ../../../../../Makefile.config
 
## Sources
#
 
OUTPUT = netstart
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/networking/startup
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 4
#define NET_IP_COUNT 0
#define NET_IL_COUNT 3
#define NET_IP_COUNT 2
#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,6 → 156,22
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 ){
164,7 → 180,7
int string;
 
if( !( address && data )) return EBADMEM;
message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL );
message_id = async_send_1( phone, message, device_id, NULL );
string = measured_strings_return( phone, address, data, 1 );
async_wait_for( message_id, & result );
if(( string == EOK ) && ( result != EOK )){
171,48 → 187,27
free( * address );
free( * data );
}
return ( int ) result;
return result;
}
 
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 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_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 ( 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 );
return async_req_1_4( phone, message, device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
}
 
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_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_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 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_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){
return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service );
return async_req_3_0( phone, message, device_id, arg2, service );
}
 
#endif
/branches/network/uspace/srv/net/il/il_messages.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
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp.c
40,7 → 40,6
#include <mem.h>
#include <rwlock.h>
#include <stdio.h>
#include <task.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
51,8 → 50,8
 
#include "../../include/byteorder.h"
#include "../../include/device.h"
#include "../../include/arp_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/arp_messages.h"
#include "../../include/nil_messages.h"
#include "../../include/protocol_map.h"
 
#include "../../structures/measured_strings.h"
59,33 → 58,16
#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_messages.h"
#include "arp_wrappers.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.
152,11 → 134,7
 
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
 
int arp_task_get_id( void ){
return task_get_id();
}
 
int arp_clear_device_req( int arp_phone, device_id_t device_id ){
int arp_clear_device_wrapper( device_id_t device_id ){
arp_device_ref device;
 
rwlock_write_lock( & arp_globals.lock );
166,12 → 144,12
return ENOENT;
}
clear_device( device );
printf( "Device %d cleared\n", device_id );
printf( "\nDevice %d cleared", device_id );
rwlock_write_unlock( & arp_globals.lock );
return EOK;
}
 
int arp_clean_cache_req( int arp_phone ){
int arp_clean_cache_wrapper( void ){
int count;
arp_device_ref device;
 
186,11 → 164,11
}
arp_cache_clear( & arp_globals.cache );
rwlock_write_unlock( & arp_globals.lock );
printf( "Cache cleaned\n" );
printf( "\nCache cleaned" );
return EOK;
}
 
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
int arp_device_wrapper( device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){
ERROR_DECLARE;
 
measured_string_ref tmp;
203,7 → 181,7
return ERROR_CODE;
}
 
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_translate_wrapper( 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 );
260,7 → 238,7
device = arp_cache_find( & arp_globals.cache, device_id );
if( device ){
if( device->service != service ){
printf( "Device %d already exists\n", device->device_id );
printf( "\nDevice %d already exists", device->device_id );
rwlock_write_unlock( & arp_globals.lock );
return EEXIST;
}
282,7 → 260,7
return index;
}
}
printf( "Cache of the existing device %d cleaned\n", device->device_id );
printf( "\nCache of the existing device %d cleaned", device->device_id );
}else{
index = hardware_map( service );
if( ! index ) return ENOENT;
349,7 → 327,7
free( device );
return ERROR_CODE;
}
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 );
printf( "\nNew device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d", device->device_id, device->hardware, device->service );
}
rwlock_write_unlock( & arp_globals.lock );
return EOK;
373,7 → 351,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.net_phone, device->addr_len, device->prefix, length, device->suffix );
packet = packet_get_4( arp_globals.networking_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 );
450,7 → 428,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.net_phone, packet_get_id( packet ));
pq_release( arp_globals.networking_phone, packet_get_id( packet ));
}
}
return EOK;
471,10 → 449,6
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;
 
482,7 → 456,7
measured_string_ref translation;
char * data;
 
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST );
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_ARP_FIRST );
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
489,7 → 463,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_NETIF( call ), address ))){
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), ARP_GET_PROTO( call ), address ))){
free( address );
free( data );
}
497,7 → 471,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 ), IPC_GET_SERVICE( call ), address );
translation = arp_translate_message( IPC_GET_DEVICE( call ), ARP_GET_PROTO( call ), address );
free( address );
free( data );
if( ! translation ){
508,9 → 482,9
rwlock_read_unlock( & arp_globals.lock );
return ERROR_CODE;
case NET_ARP_CLEAR_DEVICE:
return arp_clear_device_req( 0, IPC_GET_DEVICE( call ));
return arp_clear_device_wrapper( IPC_GET_DEVICE( call ));
case NET_ARP_CLEAN_CACHE:
return arp_clean_cache_req( 0 );
return arp_clean_cache_wrapper();
}
return ENOTSUP;
}
527,7 → 501,7
ipc_answer_0( iid, EOK );
break;
case NET_IL_RECEIVED:
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){
if( ! ERROR_OCCURRED( packet_translate( arp_globals.networking_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_wrappers.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 arp
* @{
*/
 
/** @file
*/
 
#ifndef __NET_ARP_WRAPPERS_H__
#define __NET_ARP_WRAPPERS_H__
 
#include <ipc/services.h>
 
#include "../../structures/measured_strings.h"
 
#include "../../include/device.h"
 
/** 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_wrapper( device_id_t device_id );
 
/** Clears the whole cache.
* @returns EOK on success.
*/
int arp_clean_cache_wrapper( void );
 
int arp_device_wrapper( device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address );
int arp_translate_wrapper( device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/arp/arp.h
160,7 → 160,7
struct arp_globals{
/** Networking module phone.
*/
int net_phone;
int networking_phone;
/** Safety lock.
*/
rwlock_t lock;
/branches/network/uspace/srv/net/il/arp/arp_module.c
46,8 → 46,6
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "arp.h"
60,7 → 58,7
/** Prints the module name.
* @see NAME
*/
void module_print_name( void );
void arp_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.
69,24 → 67,23
* @returns Other error codes as defined for the arp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
*/
int module_start( async_client_conn_t client_connection );
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int arp_start_module( async_client_conn_t client_connection );
 
/** ARP module global data.
*/
extern arp_globals_t arp_globals;
 
void module_print_name( void ){
void arp_print_name( void ){
printf( "%s", NAME );
}
 
int module_start( async_client_conn_t client_connection ){
int arp_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
arp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
arp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( arp_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ARP, & phonehash ))){
100,9 → 97,5
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,9 → 43,8
$(STRUCTURES)char_map.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)/packet/packet_client.c \
$(STRUCTURES)/packet/packet_remote.c \
$(NET_BASE)nil/nil_remote.c \
$(NET_BASE)net/net_remote.c
$(STRUCTURES)packet/packet_client.c
 
NET_DEFS += -D ARP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/il/ip/ip_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip.c
44,23 → 44,17
#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_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
#include "../../include/ip_interface.h"
#include "../../include/arp_messages.h"
#include "../../include/nil_messages.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
68,6 → 62,10
#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 )
74,9 → 72,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.
*/
86,60 → 84,92
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, arp_task_get_id(), arp_connect_module ));
ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, 0 ));
return EOK;
}
 
int ip_device_req( int il_phone, device_id_t device_id, services_t service ){
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 ){
ERROR_DECLARE;
 
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;
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;
 
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
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 );
// 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 );
}else{
ip_netif->ipv = DEFAULT_IPV;
}
ip_netif->dhcp = ! strncmp( configuration[ 1 ].value, "dhcp", 4 );
ip_netif->dhcp = ! strncmp( settings[ 1 ].value, "dhcp", 4 );
if( ip_netif->dhcp ){
// TODO dhcp
net_free_settings( configuration, data );
free( settings );
free( data );
free( ip_netif );
return ENOTSUP;
}else if( ip_netif->ipv == 4 ){
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 );
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 );
free( ip_netif );
return EINVAL;
}
}else{
// TODO ipv6
net_free_settings( configuration, data );
free( settings );
free( data );
free( ip_netif );
return ENOTSUP;
}
if( configuration[ 8 ].value ){
ip_netif->arp = get_running_module( & ip_globals.modules, configuration[ 8 ].value );
if( settings[ 8 ].value ){
ip_netif->arp = get_running_module( & ip_globals.modules, settings[ 8 ].value );
if( ! ip_netif->arp ){
printf( "Failed to start the arp %s\n", configuration[ 8 ].value );
net_free_settings( configuration, data );
printf( "\nFailed to start the arp %s", settings[ 8 ].value );
free( settings );
free( data );
free( ip_netif );
return EINVAL;
}
146,11 → 176,12
}else{
ip_netif->arp = NULL;
}
net_free_settings( configuration, data );
free( settings );
free( data );
}
ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
if( ip_netif->phone < 0 ){
printf( "Failed to contact the nil service %d\n", service );
printf( "\nFailed to contact the nil service %d", service );
free( ip_netif );
return ip_netif->phone;
}
169,23 → 200,23
}
if( ip_netif->arp ) ++ ip_netif->arp->usage;
// print the settings
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" );
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" );
// TODO ipv6 addresses
data = malloc( INET_ADDRSTRLEN );
if( data ){
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->address, data, INET_ADDRSTRLEN );
printf( "\taddress\t= %s\n", data );
printf( "\n\taddress\t= %s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN );
printf( "\tnetmask\t= %s\n", data );
printf( "\n\tnetmask\t= %s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN );
printf( "\tgateway\t= %s\n", data );
printf( "\n\tgateway\t= %s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN );
printf( "\tbroadcast\t= %s\n", data );
printf( "\n\tbroadcast\t= %s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
printf( "\tdns1\t= %s\n", data );
printf( "\n\tdns1\t= %s", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
printf( "\tdns2\t= %s\n", data );
printf( "\n\tdns2\t= %s", data );
free( data );
}
return EOK;
223,22 → 254,20
switch( IPC_GET_METHOD( call )){
case NET_IL_DEVICE_STATE:
case NET_NIL_DEVICE_STATE:
result = ip_device_state_msg( 0, IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
result = ip_state_message( 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.net_phone, & packet, IPC_GET_PACKET( & call )))){
//result = il_receive_msg( 0, IPC_GET_DEVICE( call ), packet );
if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
//result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
}
ipc_answer_0( callid, result );
break;
}
}
}
 
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
int ip_state_message( device_id_t device_id, device_state_t state ){
ERROR_DECLARE;
 
ip_netif_ref netif;
250,12 → 279,12
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ) return ENOENT;
// TODO state
printf( "ip - device %d changed state to %d\n\n", device_id, state );
printf( "\nip - device %d changed state to %d\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( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
free( translation );
free( data );
}
262,16 → 291,7
return EOK;
}
 
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 ){
int ip_register_message( int protocol, int phone ){
ip_proto_ref proto;
int index;
 
284,14 → 304,14
free( proto );
return index;
}
printf( "New protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d\n", proto->protocol, proto->phone );
printf( "\nNew protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d", proto->protocol, proto->phone );
return EOK;
}
 
int ip_send_msg( int il_phone, device_id_t device_id, packet_t packet, services_t target ){
int ip_send_message( device_id_t device_id, packet_t packet ){
// TODO send 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 ));
printf( "Packet to send via %d: %s", device_id, packet_get_data( packet ));
pq_release( ip_globals.networking_phone, packet_get_id( packet ));
return EOK;
}
 
304,13 → 324,16
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_req( 0, IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
case IPC_M_CONNECT_TO_ME:
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 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 ENOTSUP;
}
/branches/network/uspace/srv/net/il/ip/ip.h
77,7 → 77,7
};
 
struct ip_globals{
int net_phone;
int networking_phone;
ip_netifs_t netifs;
ip_protos_t protos;
modules_t modules;
/branches/network/uspace/srv/net/il/ip/ip_module.c
42,8 → 42,6
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "ip.h"
51,23 → 49,22
 
#define NAME "IP protocol"
 
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 );
void ip_print_name( void );
int ip_start_module( async_client_conn_t client_connection );
 
extern ip_globals_t ip_globals;
 
void module_print_name( void ){
void ip_print_name( void ){
printf( "%s", NAME );
}
 
int module_start( async_client_conn_t client_connection ){
int ip_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
ip_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
ip_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( ip_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_IP, & phonehash ))){
81,9 → 78,5
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/il/ip/Makefile
31,9 → 31,6
NET_BASE = ../../
STRUCTURES = $(NET_BASE)structures/
 
## Sources
#
 
OUTPUT = $(NAME)
SOURCES = \
$(NAME)_module.c \
44,11 → 41,9
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)module_map.c \
$(STRUCTURES)packet/packet.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
$(STRUCTURES)packet/packet_client.c \
$(NET_BASE)sockaddr.c
 
NET_DEFS += -D IP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/il/ip/ip_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 ip
* @{
*/
 
/** @file
*/
 
#ifndef __NET_IP_MESSAGES_H__
#define __NET_IP_MESSAGES_H__
 
#include <async.h>
 
#include <ipc/ipc.h>
 
#include "../../err.h"
#include "../../messages.h"
 
#include "../../structures/packet/packet.h"
 
#if IP_BUNDLE
 
int ip_device_message( device_id_t device_id, services_t service );
int ip_echo_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t * res1, ipcarg_t * res2, ipcarg_t * res3, ipcarg_t * res4, ipcarg_t * res5 );
int ip_send_message( device_id_t device_id, packet_t packet );
 
#define ip_device( ip_phone, device_id, service ) \
ip_device_message(( device_id ), ( service ))
 
#define ip_echo( ip_phone, arg1, arg2, arg3, arg4, arg5, answer1, answer2, answer3, answer4, answer5 ) \
ip_echo_message(( arg1 ), ( arg2 ), ( arg3 ), ( arg4 ), ( arg5 ), ( answer1 ), ( answer2 ), ( answer3 ), ( answer4 ), ( answer5 ))
 
#define ip_send( ip_phone, device_id, packet ) \
ip_send_message(( device_id ), ( packet ));
#else
 
#define ip_device( ip_phone, device_id, service ) \
ipc_sync_send_2_0( ip_phone, NET_IP_DEVICE, ( device_id ), ( service ))
 
#define ip_echo( ip_phone, arg1, arg2, arg3, arg4, arg5, answer1, answer2, answer3, answer4, answer5 ) \
async_req_5_5( ip_phone, NET_IP_ECHO, ( arg1 ), ( arg2 ), ( arg3 ), ( arg4 ), ( arg5 ), ( answer1 ), ( answer2 ), ( answer3 ), ( answer4 ), ( answer5 ))
 
#define ip_send( ip_phone, device_id, packet ) \
async_msg_1( ip_phone, NET_IP_SEND, packet_get_id( packet ))
 
#endif
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_messages.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
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/netif/netif_nil_bundle.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_standalone.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/netif_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/netif/netif.c
50,20 → 50,28
#include "../structures/measured_strings.h"
 
#include "../include/device.h"
#include "../include/netif_interface.h"
#include "../include/nil_interface.h"
#include "../include/netif_messages.h"
#include "../include/nil_messages.h"
 
#include "netif.h"
#include "netif_messages.h"
#include "netif_module.h"
#include "netif_interface.h"
#include "netif_wrappers.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_req( int netif_phone, device_id_t device_id, int irq, int io ){
int netif_probe_wrapper( device_id_t device_id, int irq, int io ){
int result;
 
rwlock_write_lock( & netif_globals.lock );
72,7 → 80,7
return result;
}
 
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender ){
int netif_send_wrapper( device_id_t device_id, packet_t packet, services_t sender ){
int result;
 
rwlock_write_lock( & netif_globals.lock );
81,7 → 89,7
return result;
}
 
int netif_start_req( int netif_phone, device_id_t device_id ){
int netif_start_wrapper( device_id_t device_id ){
ERROR_DECLARE;
 
device_ref device;
105,7 → 113,7
return result;
}
 
int netif_stop_req( int netif_phone, device_id_t device_id ){
int netif_stop_wrapper( device_id_t device_id ){
ERROR_DECLARE;
 
device_ref device;
129,7 → 137,7
return result;
}
 
int netif_get_addr( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data ){
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address, char ** data ){
ERROR_DECLARE;
 
measured_string_t translation;
141,14 → 149,9
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 );
169,7 → 172,7
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->nil_phone > 0 ) return ELIMIT;
device->nil_phone = phone;
printf( "New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone );
printf( "\nNew receiver of the device %d registered:\n\tphone\t= %d", device->device_id, device->nil_phone );
return EOK;
}
 
181,7 → 184,12
packet_t packet;
measured_string_t address;
 
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NETIF_FIRST );
// 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
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
192,18 → 200,22
rwlock_write_unlock( & netif_globals.lock );
return ERROR_CODE;
case NET_NETIF_PROBE:
return netif_probe_req( 0, IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call ));
return netif_probe_wrapper( 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.net_phone, & packet, IPC_GET_PACKET( call )));
return netif_send_msg( 0, IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call ));
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 ));
case NET_NETIF_START:
return netif_start_req( 0, IPC_GET_DEVICE( call ));
return netif_start_wrapper( IPC_GET_DEVICE( call ));
case NET_NETIF_STATS:
rwlock_read_lock( & netif_globals.lock );
if( ! ERROR_OCCURRED( ipc_data_read_receive( & callid, & length ))){
218,7 → 230,7
rwlock_read_unlock( & netif_globals.lock );
return ERROR_CODE;
case NET_NETIF_STOP:
return netif_stop_req( 0, IPC_GET_DEVICE( call ));
return netif_stop_wrapper( IPC_GET_DEVICE( call ));
case NET_NETIF_GET_ADDR:
case NET_NIL_ADDR:
rwlock_read_lock( & netif_globals.lock );
231,11 → 243,11
return netif_specific_message( callid, call, answer, answer_count );
}
 
int netif_init_module( async_client_conn_t client_connection ){
int netif_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
async_set_client_connection( client_connection );
netif_globals.net_phone = connect_to_service( SERVICE_NETWORKING );
netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
device_map_initialize( & netif_globals.device_map );
ERROR_PROPAGATE( pm_init());
rwlock_initialize( & netif_globals.lock );
243,10 → 255,13
pm_destroy();
return ERROR_CODE;
}
return EOK;
}
#if NIL_BUNDLE
if( ERROR_OCCURRED( nil_initialize( netif_globals.networking_phone ))){
pm_destroy();
return ERROR_CODE;
}
#endif
 
int netif_run_module( void ){
async_manager();
 
pm_destroy();
254,11 → 269,11
}
 
void netif_pq_release( packet_id_t packet_id ){
pq_release( netif_globals.net_phone, packet_id );
pq_release( netif_globals.networking_phone, packet_id );
}
 
packet_t netif_packet_get_1( size_t content ){
return packet_get_1( netif_globals.net_phone, content );
return packet_get_1( netif_globals.networking_phone, content );
}
 
/** @}
/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_interface.h"
#include "../../include/nil_messages.h"
 
#include "../netif.h"
#include "../netif_module.h"
#include "../netif_interface.h"
 
#include "dp8390.h"
#include "dp8390_drv.h"
89,7 → 89,7
 
netif_globals_t netif_globals;
 
void module_print_name( void );
void netif_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 module_print_name( void ){
void netif_print_name( void ){
printf( "%s", NAME );
}
 
149,7 → 149,7
int phone;
 
device_id = IRQ_GET_DEVICE( call );
// printf( "device %d - irq %x\n", device_id, IPC_GET_ISR( call ));
// printf( "\ndevice %d - irq %x", 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( "dev %d, irq %x\n\n", device->device_id, IPC_GET_ISR( call ));
// printf( "\ndev %d, irq %x\n", device->device_id, IPC_GET_ISR( call ));
if ( dep->de_mode != DEM_ENABLED){
// continue;
rwlock_write_unlock( & netif_globals.lock );
199,6 → 199,7
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 ));
238,7 → 239,7
 
uint8_t * data;
data = packet_get_data( packet );
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 ] );
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 ] );
 
ERROR_PROPAGATE( find_device( device_id, & device ));
dep = ( dpeth_t * ) device->specific;
286,7 → 287,7
 
int change_state( device_ref device, device_state_t state ){
device->state = state;
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
return state;
}
 
/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!\n" );
printf( "map_hw_buffer: no buffer!" );
}
 
// size = dep->de_ramsize + PAGE_SIZE; /* Add PAGE_SIZE for
/branches/network/uspace/srv/net/netif/dp8390/Makefile
37,28 → 37,27
#
 
OUTPUT = dp8390
REBUILD = $(OUTPUT)_module.c \
../$(NAME).c
SOURCES = \
$(OUTPUT).c \
$(OUTPUT)_module.c \
../$(NAME).c \
$(REBUILD) \
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_remote.c
$(STRUCTURES)packet/packet.c
 
NET_DEFS += -D NETIF_BUNDLE=1
 
ifeq ($(NETWORKING), module)
 
SOURCES += ../$(NAME)_nil_bundle.c \
$(NET_BASE)crc.c \
$(NET_BASE)nil/eth/eth.c
SOURCES += $(NET_BASE)crc.c
 
else
REBUILD += $(NET_BASE)nil/eth/eth.c
 
SOURCES += ../$(NAME)_standalone.c \
$(NET_BASE)nil/nil_remote.c
NET_DEFS += -D NIL_BUNDLE=1
 
endif
 
/branches/network/uspace/srv/net/netif/netif_wrappers.h
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 netif
* @{
*/
 
#ifndef __NET_NETIF_WRAPPERS_H__
#define __NET_NETIF_WRAPPERS_H__
 
#include <ipc/services.h>
 
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
 
#include "../include/device.h"
 
int netif_probe_wrapper( device_id_t device_id, int irq, int io );
int netif_send_wrapper( device_id_t device_id, packet_t packet, services_t sender );
int netif_start_wrapper( device_id_t device_id );
int netif_stop_wrapper( device_id_t device_id );
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address, char ** data );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/netif/lo/lo.c
48,11 → 48,10
#include "../../structures/packet/packet_client.h"
 
#include "../../include/device.h"
#include "../../include/nil_interface.h"
#include "../../include/net_interface.h"
#include "../../include/nil_messages.h"
 
#include "../netif.h"
#include "../netif_module.h"
#include "../netif_interface.h"
 
#define DEFAULT_MTU 1500
 
64,12 → 63,12
netif_globals_t netif_globals;
 
static struct lo_globals{
unsigned int mtu;
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 module_print_name( void );
void netif_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
97,7 → 96,7
static int change_state_message( device_ref device, device_state_t state ){
if( device->state != state ){
device->state = state;
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
return state;
}
return EOK;
137,7 → 136,7
return REGISTER_ME( SERVICE_LO, & phonehash );
}
 
void module_print_name( void ){
void netif_print_name( void ){
printf( "%s", NAME );
}
 
147,7 → 146,7
device_ref device;
 
ERROR_PROPAGATE( create( arg1, & device ));
ipc_call_sync_3_3( netif_globals.net_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
*/ return ENOTSUP;
}
 
154,26 → 153,44
int netif_probe_message( device_id_t device_id, int irq, int io ){
ERROR_DECLARE;
 
device_ref device;
measured_string_t names[ 1 ] = {{ "MTU", 3 }};
measured_string_ref configuration;
int count = 1;
char * data;
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;
 
configuration = & names[ 0 ];
// create a new device
ERROR_PROPAGATE( create( device_id, & device ));
// get configuration
ERROR_PROPAGATE( net_get_device_conf_req( netif_globals.net_phone, device->device_id, & configuration, count, & data ));
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;
}
// MTU is the first one
if( configuration && configuration[ 0 ].value ){
lo_globals.mtu = strtoul( configuration[ 0 ].value, NULL, 0 );
net_free_settings( configuration, data );
if( settings && ( settings[ 0 ].value )){
lo_globals.mtu = strtoul( settings[ 0 ].value, NULL, 0 );
free( settings );
free( data );
}else{
lo_globals.mtu = DEFAULT_MTU;
}
// print the settings
printf("New device registered:\n\tid\t= %d\n\tMTU\t= %d\n", device->device_id, lo_globals.mtu );
printf("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
return EOK;
}
 
/branches/network/uspace/srv/net/netif/lo/Makefile
35,17 → 35,16
#
 
OUTPUT = lo
REBUILD = ../$(NAME).c
SOURCES = \
$(OUTPUT).c \
../$(NAME).c \
$(REBUILD) \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)packet/packet.c \
$(STRUCTURES)packet/packet_client.c \
$(STRUCTURES)packet/packet_remote.c \
$(NET_BASE)nil/nil_remote.c \
../$(NAME)_standalone.c \
$(NET_BASE)net/net_remote.c
$(STRUCTURES)packet/packet.c
 
NET_DEFS += -D NETIF_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/netif/netif.h
37,17 → 37,10
#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;
90,7 → 83,7
struct netif_globals{
/** Networking module phone.
*/
int net_phone;
int networking_phone;
/** Device map.
*/
device_map_t device_map;
122,10 → 115,6
*/
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_interface.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_INTERFACE_H__
#define __NET_NETIF_INTERFACE_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
/branches/network/uspace/srv/net/Makefile.module
40,7 → 40,7
 
LIBS = $(LIBC_PREFIX)/libc.a
 
DEFS += $(NET_DEFS)
DEFS += $(NET_DEFS) -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
DISASMS := $(addsuffix .disasm,$(basename $(OUTPUT)))
55,14 → 55,17
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(OUTPUT).map $(addsuffix .map,$(basename $(SOURCES))) $(DISASMS) Makefile.depend
-rm -f $(OUTPUT) $(addsuffix .map,$(basename $(SOURCES))) $(DISASMS) Makefile.depend
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
 
$(OUTPUT): $(OBJECTS) $(LIBS)
$(OUTPUT): freshen $(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/nil/nil_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/nil/nil_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:mergeinfo
/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_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
#include "../../include/netif_messages.h"
#include "../../include/nil_messages.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,8 → 95,7
INT_MAP_IMPLEMENT( eth_protos, eth_proto_t )
 
int eth_device_message( device_id_t device_id, services_t service, size_t mtu );
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_receive_message( device_id_t device_id, packet_t packet );
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 );
103,7 → 102,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 );
 
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state ){
void nil_device_state_wrapper( device_id_t device_id, int state ){
int index;
eth_proto_ref proto;
 
111,13 → 110,16
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 ) il_device_state_msg( proto->phone, device_id, state );
if( proto && proto->phone ) async_msg_2( proto->phone, NET_IL_DEVICE_STATE, device_id, state );
}
rwlock_read_unlock( & eth_globals.protos_lock );
return EOK;
}
 
int nil_initialize( int net_phone ){
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 ){
ERROR_DECLARE;
 
rwlock_initialize( & eth_globals.devices_lock );
124,7 → 126,7
rwlock_initialize( & eth_globals.protos_lock );
rwlock_write_lock( & eth_globals.devices_lock );
rwlock_write_lock( & eth_globals.protos_lock );
eth_globals.net_phone = net_phone;
eth_globals.networking_phone = networking_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 ));
148,13 → 150,13
device = eth_devices_find( & eth_globals.devices, device_id );
if( device ){
if( device->service != service ){
printf( "Device %d already exists\n", device->device_id );
printf( "\nDevice %d already exists", device->device_id );
rwlock_write_unlock( & eth_globals.devices_lock );
return EEXIST;
}else{
// update mtu
device->mtu = mtu;
printf( "Device %d already exists:\tMTU\t= %d\n", device->device_id, device->mtu );
printf( "\nDevice %d already exists:\tMTU\t= %d", device->device_id, device->mtu );
}
}else{
// create a new device
166,12 → 168,14
// TODO get dummy setting
device->dummy = 0;
// bind the device driver
device->phone = netif_bind_service( device->service, device->device_id, SERVICE_ETHERNET, eth_receiver );
#if ! NETIF_BUNDLE
device->phone = bind_service( device->service, device->device_id, SERVICE_ETHERNET, 0, eth_receiver );
if( device->phone < 0 ){
rwlock_write_unlock( & eth_globals.devices_lock );
free( device );
return device->phone;
}
#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 );
187,7 → 191,7
free( device );
return index;
}
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 ] );
printf( "\nNew device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X", device->device_id, device->service, device->mtu, device->addr_data[ 0 ], device->addr_data[ 1 ], device->addr_data[ 2 ], device->addr_data[ 3 ], device->addr_data[ 4 ], device->addr_data[ 5 ] );
}
rwlock_write_unlock( & eth_globals.devices_lock );
return EOK;
250,7 → 254,7
return eth_protos_find( & eth_globals.protos, type );
}
 
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target ){
int eth_receive_message( device_id_t device_id, packet_t packet ){
eth_proto_ref proto;
packet_t next;
eth_device_ref device;
269,10 → 273,10
next = pq_detach( packet );
proto = eth_process_packet( dummy, packet );
if( proto ){
il_received_msg( proto->phone, device_id, packet, proto->service );
async_msg_3( proto->phone, NET_IL_RECEIVED, device_id, packet_get_id( packet ), proto->service );
}else{
// drop invalid/unknown
pq_release( eth_globals.net_phone, packet_get_id( packet ));
pq_release( eth_globals.networking_phone, packet_get_id( packet ));
}
packet = next;
}while( packet );
346,7 → 350,7
return index;
}
}
printf( "New protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d\n", proto->protocol, proto->service, proto->phone );
printf( "\nNew protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d", proto->protocol, proto->service, proto->phone );
rwlock_write_unlock( & eth_globals.protos_lock );
return EOK;
}
405,7 → 409,7
 
ethertype = htons( protocol_map( SERVICE_ETHERNET, sender ));
if( ! ethertype ){
pq_release( eth_globals.net_phone, packet_get_id( packet ));
pq_release( eth_globals.networking_phone, packet_get_id( packet ));
return EINVAL;
}
rwlock_read_lock( & eth_globals.devices_lock );
420,7 → 424,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.net_phone, packet_get_id( next ));
pq_release( eth_globals.networking_phone, packet_get_id( next ));
next = tmp;
}else{
next = pq_next( next );
438,7 → 442,7
measured_string_ref address;
packet_t packet;
 
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NIL_FIRST );
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_NIL_FIRST );
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
446,7 → 450,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.net_phone, & packet, IPC_GET_PACKET( call )));
ERROR_PROPAGATE( packet_translate( eth_globals.networking_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 )));
472,12 → 476,12
while( true ){
switch( IPC_GET_METHOD( * icall )){
case NET_NIL_DEVICE_STATE:
nil_device_state_msg( 0, IPC_GET_DEVICE( icall ), IPC_GET_STATE( icall ));
nil_device_state_wrapper( 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.net_phone, & packet, IPC_GET_PACKET( icall )))){
ERROR_CODE = nil_received_msg( 0, IPC_GET_DEVICE( icall ), packet, 0 );
if( ! ERROR_OCCURRED( packet_translate( eth_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){
ERROR_CODE = nil_receive_wrapper( IPC_GET_DEVICE( icall ), packet );
}
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 net_phone;
int networking_phone;
/** Safety lock for devices.
*/
rwlock_t devices_lock;
/branches/network/uspace/srv/net/nil/eth/eth_module.c
42,8 → 42,6
#include "../../err.h"
#include "../../modules.h"
 
#include "../../include/net_interface.h"
 
#include "../../structures/packet/packet.h"
 
#include "../nil_module.h"
52,26 → 50,25
 
#define NAME "Ethernet protocol"
 
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 );
void eth_print_name( void );
int eth_start_module( async_client_conn_t client_connection );
 
extern eth_globals_t eth_globals;
 
void module_print_name( void ){
void eth_print_name( void ){
printf( "%s", NAME );
}
 
int module_start( async_client_conn_t client_connection ){
int eth_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
int net_phone;
int networking_phone;
 
async_set_client_connection( client_connection );
net_phone = net_connect_module( SERVICE_NETWORKING );
networking_phone = connect_to_service( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( nil_initialize( net_phone ))
if( ERROR_OCCURRED( nil_initialize( networking_phone ))
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ETHERNET, & phonehash ))){
pm_destroy();
return ERROR_CODE;
83,9 → 80,5
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,15 → 35,13
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_remote.c \
$(NET_BASE)netif/netif_remote.c \
$(NET_BASE)net/net_remote.c
$(STRUCTURES)packet/packet_client.c
 
NET_DEFS += -D NIL_BUNDLE=1 -Dnil_message=$(NAME)_message
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/nil/nil_wrappers.h
0,0 → 1,46
/*
* 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
* @{
*/
 
#ifndef __NET_NIL_WRAPPERS_H__
#define __NET_NIL_WRAPPERS_H__
 
#include "../include/device.h"
 
#include "../structures/packet/packet.h"
 
void nil_device_state_wrapper( device_id_t device_id, int state );
int nil_receive_wrapper( device_id_t device_id, packet_t packet );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/nil/nil_module.h
40,6 → 40,7
 
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/Makefile
31,13 → 31,13
DIRS = \
netif/lo \
netif/dp8390 \
nil/eth \
net \
net/start
networking \
networking/startup
 
DIRS_MODULAR = il/ip \
tl/tcp \
il/arp \
nil/eth \
# il/rarp \
# il/icmp \
# tl/udp \
/branches/network/uspace/srv/net/tl/tcp/tcp_module.c
44,9 → 44,7
 
#include "../../structures/packet/packet.h"
 
#include "../../include/net_interface.h"
#include "../../include/ip_protocols.h"
#include "../../include/ip_interface.h"
#include "../../include/protocols.h"
 
#include "tcp.h"
#include "tcp_module.h"
53,24 → 51,23
 
#define NAME "TCP protocol"
 
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 );
void tcp_print_name( void );
int tcp_start_module( async_client_conn_t client_connection );
 
extern tcp_globals_t tcp_globals;
 
void module_print_name( void ){
void tcp_print_name( void ){
printf( "%s", NAME );
}
 
int module_start( async_client_conn_t client_connection ){
int tcp_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
tcp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
tcp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_TCP, 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 );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( tcp_initialize())
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_TCP, & phonehash ))){
84,9 → 81,5
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/tcp.c
44,7 → 44,7
#include "../../modules.h"
#include "../../structures/packet/packet_client.h"
 
#include "../../include/ip_interface.h"
#include "../../il/ip/ip_messages.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( "TCP - testing to send to IP:\n" );
printf( "\nTCP - testing to send to IP:\t" );
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( "TCP - testing to send packet to IP:\n" );
packet = packet_get_4( tcp_globals.net_phone, 6, 20, 30, 20 );
 
printf( "\nTCP - testing to send packet to IP:\t" );
packet = packet_get_4( tcp_globals.networking_phone, 6, 20, 30, 20 );
if( ! packet ) return ENOMEM;
packet_copy_data( packet, "Hi, this is TCP", 16 );
ip_send_msg( tcp_globals.ip_phone, -1, packet, SERVICE_TCP );
printf( "OK\n" );
ip_send( tcp_globals.ip_phone, -1, packet );
printf( "\tOK\n" );
return EOK;
}
 
/branches/network/uspace/srv/net/tl/tcp/Makefile
41,10 → 41,8
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(STRUCTURES)packet/packet.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
$(STRUCTURES)packet/packet_client.c
 
NET_DEFS += -D TCP_BUNDLE=1
 
include $(NET_BASE)Makefile.module
/branches/network/uspace/srv/net/tl/tcp/tcp.h
40,7 → 40,7
 
struct tcp_globals{
int ip_phone;
int net_phone;
int networking_phone;
};
 
#endif
/branches/network/uspace/srv/net/modules.h
33,9 → 33,6
/** @file
*/
 
#ifndef __NET_MODULES_H__
#define __NET_MODULES_H__
#include <async.h>
 
#include <ipc/ipc.h>
50,12 → 47,8
 
#define REGISTER_ME( me, phonehash ) ipc_connect_to_me( PHONE_NS, ( me ), 0, 0, ( phonehash ))
 
typedef int connect_module_t( services_t need );
 
connect_module_t connect_to_service;
int connect_to_service( services_t need );
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/module.c
101,11 → 101,10
int main( int argc, char * argv[] ){
ERROR_DECLARE;
 
printf("Task %d - ", task_get_id());
printf("\nTask %d - ", task_get_id());
module_print_name();
printf( "\n" );
if( ERROR_OCCURRED( module_start( client_connection ))){
printf( " - ERROR %i\n", ERROR_CODE );
printf( " - ERROR %i", ERROR_CODE );
return ERROR_CODE;
}
return EOK;
/branches/network/uspace/srv/net/err.h
39,12 → 39,6
 
#include <errno.h>
 
#ifdef CONFIG_DEBUG
 
#include <stdio.h>
 
#endif
 
/** An actual stored error code.
*/
#define ERROR_CODE error_check_return_value
64,17 → 58,9
/** 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,11 → 46,10
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/net/net/net \
$(USPACEDIR)/srv/net/net/start/netstart \
$(USPACEDIR)/srv/net/networking/net \
$(USPACEDIR)/srv/net/networking/startup/netstart \
$(USPACEDIR)/srv/net/netif/lo/lo \
$(USPACEDIR)/srv/net/netif/dp8390/dp8390 \
$(USPACEDIR)/srv/net/nil/eth/eth
$(USPACEDIR)/srv/net/netif/dp8390/dp8390
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
63,6 → 62,7
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 \