Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3845 → Rev 3846

/branches/network/uspace/doc/doxygroups.h
31,6 → 31,16
* @ingroup srvcs
*/
 
/**
* @defgroup arp Address Resolution Protocol (ARP) Service
* @ingroup net
*/
 
/**
* @defgroup eth Ethernet network interface layer Service
* @ingroup net
*/
 
/**
* @cond amd64
* @defgroup pci PCI Service
/branches/network/uspace/srv/net/arp/arp_header.h
0,0 → 1,55
/*
* Copyright (c) 2008 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_HEADER_H__
#define __NET_ARP_HEADER_H__
 
#include <sys/types.h>
 
typedef struct arp_header arp_header_t;
typedef arp_header_t * arp_header_ref;
 
struct arp_header{
uint16_t hardware;
uint16_t protocol;
uint8_t hardware_length;
uint8_t protocol_length;
uint16_t operation;
};
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/arp.c
===================================================================
--- network/uspace/srv/net/arp/arp.c (nonexistent)
+++ network/uspace/srv/net/arp/arp.c (revision 3846)
@@ -0,0 +1,428 @@
+/*
+ * Copyright (c) 2008 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup arp
+ * @{
+ */
+
+/** @file
+ */
+
+#include <as.h>
+#include <async.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include "../err.h"
+#include "../measured_strings.h"
+#include "../messages.h"
+#include "../modules.h"
+#include "../packet.h"
+
+#include "../include/protocol_map.h"
+#include "../netif/device.h"
+
+#include "arp.h"
+#include "arp_header.h"
+#include "arp_oc.h"
+//#include "arp_messages.h"
+#include "arp_module.h"
+
+#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
+#define IPC_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call )
+#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call )
+
+arp_globals_t arp_globals;
+
+DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
+
+INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
+
+GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
+
+int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address );
+int arp_device_message( device_id_t device_id, services_t service, services_t protocol, measured_string_ref address );
+measured_string_ref arp_translate_message( device_id_t device, services_t protocol, measured_string_ref target );
+int arp_receive_message( device_id_t device_id, packet_t packet );
+int arp_clear_device_message( device_id_t device_id );
+void clear_device( arp_device_ref device );
+int arp_clean_cache_message( void );
+void arp_receiver( ipc_callid_t iid, ipc_call_t * icall );
+
+/** Initializes the ARP module.
+ */
+int arp_initialize( void ){
+ arp_cache_initialize( & arp_globals.cache );
+ return EOK;
+}
+
+int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address ){
+ ERROR_DECLARE;
+
+ * proto = ( arp_proto_ref ) malloc( sizeof( arp_proto_t ));
+ if( !( * proto )) return ENOMEM;
+ ( ** proto ).service = service;
+ ( ** proto ).addr = address;
+ ( ** proto ).addr_data = address->value;
+ if( ERROR_OCCURED( arp_addr_initialize( &( ** proto).addresses ))){
+ free( * proto );
+ return ERROR_CODE;
+ }
+ return EOK;
+}
+
+int arp_device_message( device_id_t device_id, services_t service, services_t protocol, measured_string_ref address ){
+ ERROR_DECLARE;
+
+ arp_device_ref device;
+ aid_t message;
+ ipc_call_t answer;
+ ipcarg_t result;
+ arp_proto_ref proto;
+
+ // an existing device?
+ device = arp_cache_find( & arp_globals.cache, device_id );
+ if( device ){
+ if( device->service != service ) return EEXIST;
+ proto = arp_protos_find( & device->protos, protocol );
+ if( proto ){
+ free( proto->addr );
+ free( proto->addr_data );
+ proto->addr = address;
+ proto->addr_data = address->value;
+ }else{
+ ERROR_PROPAGATE( arp_proto_create( & proto, protocol, address ));
+ if( ERROR_OCCURED( arp_protos_add( & device->protos, proto->service, proto ))){
+ free( proto );
+ return ERROR_CODE;
+ }
+ }
+ return EOK;
+ }else{
+ // create a new device
+ device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
+ if( ! device ) return ENOMEM;
+ device->device_id = device_id;
+ if( ERROR_OCCURED( arp_protos_initialize( & device->protos ))
+ || ERROR_OCCURED( arp_proto_create( & proto, protocol, address ))){
+ free( device );
+ return ERROR_CODE;
+ }
+ if( ERROR_OCCURED( arp_protos_add( & device->protos, proto->service, proto ))){
+ arp_protos_destroy( & device->protos );
+ free( device );
+ return ERROR_CODE;
+ }
+ device->service = service;
+ // bind the new one
+ device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_receiver );
+ // get packet dimensions
+ if( ERROR_OCCURED( async_req_1_3( device->phone, NET_NIL_PACKET_SPACE, device_id, & device->prefix, & device->content, & device->sufix ))){
+ arp_protos_destroy( & device->protos );
+ free( device );
+ return ERROR_CODE;
+ }
+ // get hardware address
+ message = async_send_1( device->phone, NET_NIL_ADDR, device->device_id, & answer );
+ if( ERROR_OCCURED( measured_strings_return( device->phone, & device->addr, & device->addr_data, 1 ))){
+ arp_protos_destroy( & device->protos );
+ free( device );
+ async_wait_for( message, NULL );
+ return ERROR_CODE;
+ }
+ async_wait_for( message, & result );
+ if( ERROR_OCCURED( result )){
+ free( device->addr );
+ free( device->addr_data );
+ arp_protos_destroy( & device->protos );
+ free( device );
+ return ERROR_CODE;
+ }
+ // get broadcast address
+ message = async_send_1( device->phone, NET_NIL_BROADCAST_ADDR, device->device_id, & answer );
+ if( ERROR_OCCURED( measured_strings_return( device->phone, & device->broadcast_addr, & device->broadcast_data, 1 ))){
+ free( device->addr );
+ free( device->addr_data );
+ arp_protos_destroy( & device->protos );
+ free( device );
+ async_wait_for( message, NULL );
+ return ERROR_CODE;
+ }
+ async_wait_for( message, & result );
+ // add to the cache
+ if( ERROR_OCCURED( result )
+ || ERROR_OCCURED( arp_cache_add( & arp_globals.cache, device->device_id, device ))){
+ free( device->addr );
+ free( device->addr_data );
+ free( device->broadcast_addr );
+ free( device->broadcast_data );
+ arp_protos_destroy( & device->protos );
+ free( device );
+ return ERROR_CODE;
+ }
+ }
+ return EOK;
+}
+
+measured_string_ref arp_translate_message( device_id_t device_id, services_t protocol, measured_string_ref target ){
+// ERROR_DECLARE;
+
+ arp_device_ref device;
+ arp_proto_ref proto;
+ measured_string_ref addr;
+ size_t length;
+ packet_t packet;
+ arp_header_ref header;
+
+ if( ! target ) return NULL;
+ device = arp_cache_find( & arp_globals.cache, device_id );
+ if( ! device ) return NULL;
+ proto = arp_protos_find( & device->protos, protocol );
+ if(( ! proto ) || ( proto->addr->length != target->length )) return NULL;
+ addr = arp_addr_find( & proto->addresses, target->value, target->length );
+ if( addr ) return addr;
+ // 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_create( device->prefix, length, device->sufix );
+ if( ! packet ) return NULL;
+ header = ( arp_header_ref ) packet_append( packet, length );
+ header->hardware = device->hardware;
+ header->hardware_length = device->addr->length;
+ header->protocol = protocol_map( device->service, protocol );
+ header->protocol_length = proto->addr->length;
+ header->operation = ARPOP_REQUEST;
+ length = sizeof( arp_header_t );
+ memcpy((( uint8_t * ) header ) + length, device->addr->value, device->addr->length );
+ length += device->addr->length;
+ memcpy((( uint8_t * ) header ) + length, proto->addr->value, proto->addr->length );
+ length += proto->addr->length;
+ memset((( uint8_t * ) header ) + length, 0, device->addr->length );
+ length += device->addr->length;
+ memcpy((( uint8_t * ) header ) + length, target->value, target->length );
+ // TODO send to the device->broadcast_addr as arp protocol
+ packet_send( packet, device->phone );
+ return NULL;
+}
+
+int arp_receive_message( device_id_t device_id, packet_t packet ){
+ ERROR_DECLARE;
+
+ size_t length;
+ arp_header_ref header;
+ arp_device_ref device;
+ arp_proto_ref proto;
+// arp_addr_ref addr;
+ measured_string_ref hw_source;
+/* measured_string_t proto_target;
+ aid_t message;
+ ipcarg_t result;
+ int index;
+ ipc_call_t answer;
+*/ int8_t * src_hw;
+ int8_t * src_proto;
+ int8_t * des_hw;
+ int8_t * des_proto;
+
+ length = packet_get_data_length( packet );
+ if( length <= sizeof( arp_header_t )) return EINVAL;
+ device = arp_cache_find( & arp_globals.cache, device_id );
+ if( ! device ) return ENOENT;
+ header = ( arp_header_ref ) packet_get_data( packet );
+ if( header->hardware != device->hardware ) return EINVAL;
+ if( length < sizeof( arp_header_t ) + ( header->hardware_length + header->protocol_length ) * 2 ) return EINVAL;
+ proto = arp_protos_find( & device->protos, protocol_unmap( device->service, header->protocol ));
+ if( ! proto ) return ENOENT;
+ src_hw = (( int8_t * ) header ) + sizeof( arp_header_t );
+ src_proto = src_hw + header->hardware_length;
+ des_hw = src_proto + header->protocol_length;
+ des_proto = des_hw + header->hardware_length;
+ hw_source = arp_addr_find( & proto->addresses, src_proto, header->protocol_length );
+ // exists?
+ if( hw_source ){
+ if( hw_source->length != header->hardware_length ) return EINVAL;
+ memcpy( hw_source->value, src_hw, header->hardware_length );
+ }
+ // is my protocol address?
+/* proto_target.value = des_proto;
+ proto_target.length = header->protocol_length;
+ // TODO send necessary?
+ message = async_send_0( proto->phone, NET_IL_MY_ADDR, & answer );
+ if( ERROR_OCCURED( measured_strings_send( device->phone, & proto_target, 1 ))){
+ async_wait_for( message, NULL );
+ return ERROR_CODE;
+ }
+ async_wait_for( message, & result );
+ if( result == EOK ){
+*/ if( proto->addr->length != header->hardware_length ) return EINVAL;
+ if( ! strncmp( proto->addr->value, des_proto, proto->addr->length )){
+ // not already upadted?
+ if( ! hw_source ){
+ hw_source = measured_string_create_bulk( src_hw, header->hardware_length );
+ if( ! hw_source ) return ENOMEM;
+ ERROR_PROPAGATE( arp_addr_add( & proto->addresses, src_proto, header->protocol_length, hw_source ));
+ }
+ if( header->operation == ARPOP_REQUEST ){
+ header->operation = ARPOP_REPLY;
+/* for( index = 0; index + header->hardware_length < header->protocol_length; index += header->hardware_length ){
+ memcpy( src_hw, src_proto + index, header->hardware_length );
+ memcpy( src_proto + index, des_proto + index, header->hardware_length );
+ memcpy( des_proto + index, src_hw, header->hardware_length );
+ }
+ memcpy( src_hw, src_proto + index, header->hardware_length - header->protocol_length );
+ memcpy( src_proto + index, des_proto + index, header->hardware_length - header->protocol_length );
+ memcpy( des_proto + index, src_hw, header->hardware_length - header->protocol_length );
+ memcpy( src_hw, des_hw, header->hardware_length );
+ memcpy( des_hw, hw_source->value, hw_source->length );
+*/ memcpy( des_proto, src_proto, header->protocol_length );
+ memcpy( src_proto, proto->addr->value, header->protocol_length );
+ memcpy( src_hw, des_hw, header->hardware_length );
+ memcpy( des_hw, hw_source->value, hw_source->length );
+ // TODO send to the hw_source as arp protocol
+ packet_send( packet, device->phone );
+ }
+ }
+ return EOK;
+}
+
+int arp_clear_device_message( device_id_t device_id ){
+ arp_device_ref device;
+
+ device = arp_cache_find( & arp_globals.cache, device_id );
+ if( ! device ) return ENOENT;
+ clear_device( device );
+ return EOK;
+}
+
+void clear_device( arp_device_ref device ){
+ int count;
+ arp_proto_ref proto;
+
+ count = arp_protos_count( & device->protos );
+ while( count > 0 ){
+ proto = arp_protos_get_index( & device->protos, count );
+ if( proto->addr ) free( proto->addr );
+ if( proto->addr_data ) free( proto->addr_data );
+ arp_addr_destroy( & proto->addresses );
+ -- count;
+ }
+ arp_protos_clear( & device->protos );
+}
+
+int arp_clean_cache_message( void ){
+ int count;
+ arp_device_ref device;
+
+ count = arp_cache_count( & arp_globals.cache );
+ while( count > 0 ){
+ device = arp_cache_get_index( & arp_globals.cache, count );
+ if( device ){
+ clear_device( device );
+ if( device->broadcast_addr ) free( device->broadcast_addr );
+ if( device->broadcast_data ) free( device->broadcast_data );
+ }
+ }
+ arp_cache_clear( & arp_globals.cache );
+ return EOK;
+}
+
+int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+ ERROR_DECLARE;
+
+// packet_t packet;
+ measured_string_ref address;
+ measured_string_ref translation;
+ char * data;
+
+ * answer_count = 0;
+ switch( IPC_GET_METHOD( * call )){
+ case IPC_M_PHONE_HUNGUP:
+ return EOK;
+ case NET_ARP_DEVICE:
+ ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
+ if( ERROR_OCCURED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), IPC_GET_PROTO( call ), address ))){
+ free( address );
+ free( data );
+ }
+ return ERROR_CODE;
+ case NET_ARP_TRANSLATE:
+ ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
+ translation = arp_translate_message( IPC_GET_DEVICE( call ), IPC_GET_PROTO( call ), address );
+ free( address );
+ free( data );
+ if( ! translation ) return ENOENT;
+ return measured_strings_reply( translation, 1 );
+ case NET_ARP_CLEAR_DEVICE:
+ return arp_clear_device_message( IPC_GET_DEVICE( call ));
+ case NET_ARP_CLEAN_CACHE:
+ return arp_clean_cache_message();
+ }
+ return ENOTSUP;
+}
+
+void arp_receiver( ipc_callid_t iid, ipc_call_t * icall ){
+ ERROR_DECLARE;
+
+ ipc_callid_t callid;
+ ipc_call_t call;
+// int result;
+ packet_t packet;
+
+ /*
+ * Accept the connection
+ * - Answer the first IPC_M_CONNECT_ME_TO call.
+ */
+ //TODO auto accept?
+ //ipc_answer_0( iid, EOK );
+
+ while( true ){
+ callid = async_get_call( & call );
+ switch( IPC_GET_METHOD( call )){
+ case NET_IL_DEVICE_STATE:
+ //TODO clear device if off?
+ break;
+ case NET_IL_RECEIVED:
+ if( ! ERROR_OCCURED( packet_receive( & packet ))){
+ ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( & call ), packet );
+ }
+ ipc_answer_0( callid, ERROR_CODE );
+ break;
+ default:
+ ipc_answer_0( callid, ENOTSUP );
+ }
+ }
+}
+
+/** @}
+ */
/network/uspace/srv/net/arp/arp.c
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/arp.h
===================================================================
--- network/uspace/srv/net/arp/arp.h (nonexistent)
+++ network/uspace/srv/net/arp/arp.h (revision 3846)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2008 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_H__
+#define __NET_ARP_H__
+
+#include <ipc/ipc.h>
+
+#include "../generic_char_map.h"
+#include "../int_map.h"
+#include "../measured_strings.h"
+
+#include "../netif/device.h"
+
+typedef struct arp_globals arp_globals_t;
+typedef arp_globals_t * arp_globals_ref;
+typedef struct arp_device arp_device_t;
+typedef arp_device_t * arp_device_ref;
+typedef struct arp_proto arp_proto_t;
+typedef arp_proto_t * arp_proto_ref;
+
+DEVICE_MAP_DECLARE( arp_cache, arp_device_t )
+
+INT_MAP_DECLARE( arp_protos, arp_proto_t )
+
+GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t )
+
+struct arp_device{
+ device_id_t device_id;
+ ipcarg_t hardware;
+ ipcarg_t protocol;
+ ipcarg_t prefix;
+ ipcarg_t content;
+ ipcarg_t sufix;
+ measured_string_ref addr;
+ char * addr_data;
+ measured_string_ref broadcast_addr;
+ char * broadcast_data;
+ services_t service;
+ int phone;
+ arp_protos_t protos;
+};
+
+struct arp_proto{
+ services_t service;
+// int phone;
+ measured_string_ref addr;
+ char * addr_data;
+ arp_addr_t addresses;
+};
+
+struct arp_globals{
+ int networking_phone;
+ arp_cache_t cache;
+};
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/arp/arp.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/arp_module.c
===================================================================
--- network/uspace/srv/net/arp/arp_module.c (nonexistent)
+++ network/uspace/srv/net/arp/arp_module.c (revision 3846)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2008 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup arp
+ * @{
+ */
+
+/** @file
+ */
+
+#include <async.h>
+#include <stdio.h>
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include "../err.h"
+#include "../modules.h"
+
+#include "arp.h"
+#include "arp_module.h"
+
+#define NAME "ARP protocol"
+
+void arp_print_name( void );
+int arp_start_module( async_client_conn_t client_connection );
+
+extern arp_globals_t arp_globals;
+
+void arp_print_name( void ){
+ printf( NAME );
+}
+
+int arp_start_module( async_client_conn_t client_connection ){
+ ERROR_DECLARE;
+
+ ipcarg_t phonehash;
+
+ async_set_client_connection( client_connection );
+ arp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
+ ERROR_PROPAGATE( arp_initialize());
+ ERROR_PROPAGATE( REGISTER_ME( SERVICE_ARP, & phonehash ));
+
+ async_manager();
+
+ return EOK;
+}
+
+/** @}
+ */
/network/uspace/srv/net/arp/arp_module.c
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/arp_oc.h
===================================================================
--- network/uspace/srv/net/arp/arp_oc.h (nonexistent)
+++ network/uspace/srv/net/arp/arp_oc.h (revision 3846)
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2008 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
+ * ARP operation codes according to the online IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
+ * Names according to the linux src/include/linux/if_arp.h header file.
+ */
+
+#ifndef __NET_ARP_ARPOP_H__
+#define __NET_ARP_ARPOP_H__
+
+/** REQUEST operation code.
+ */
+#define ARPOP_REQUEST 1
+
+/** REPLY operation code.
+ */
+#define ARPOP_REPLY 2
+
+/** Reverse request operation code.
+ */
+#define ARPOP_RREQUEST 3
+
+/** Reverse reply operation code.
+ */
+#define ARPOP_RREPLY 4
+
+/** DRARP-Request operation code.
+ */
+#define ARPOP_DRARP_Request 5
+
+/** DRARP-Reply operation code.
+ */
+#define ARPOP_DRARP_Reply 6
+
+/** DRARP-Error operation code.
+ */
+#define ARPOP_DRARP_Error 7
+
+/** InARP-Request operation code.
+ */
+#define ARPOP_InREQUEST 8
+
+/** InARP-Reply operation code.
+ */
+#define ARPOP_InREPLY 9
+
+/** ARP-NAK operation code.
+ */
+#define ARPOP_NAK 10
+
+/** MARS-Request operation code.
+ */
+#define ARPOP_MARS_Request 11
+
+/** MARS-Multi operation code.
+ */
+#define ARPOP_MARS_Multi 12
+
+/** MARS-MServ operation code.
+ */
+#define ARPOP_MARS_MServ 13
+
+/** MARS-Join operation code.
+ */
+#define ARPOP_MARS_Join 14
+
+/** MARS-Leave operation code.
+ */
+#define ARPOP_MARS_Leave 15
+
+/** MARS-NAK operation code.
+ */
+#define ARPOP_MARS_NAK 16
+
+/** MARS-Unserv operation code.
+ */
+#define ARPOP_MARS_Unserv 17
+
+/** MARS-SJoin operation code.
+ */
+#define ARPOP_MARS_SJoin 18
+
+/** MARS-SLeave operation code.
+ */
+#define ARPOP_MARS_SLeave 19
+
+/** MARS-Grouplist-Request operation code.
+ */
+#define ARPOP_MARS_Grouplist_Request 20
+
+/** MARS-Grouplist-Reply operation code.
+ */
+#define ARPOP_MARS_Grouplist_Reply 21
+
+/** MARS-Redirect-Map operation code.
+ */
+#define ARPOP_MARS_Redirect_Map 22
+
+/** MAPOS-UNARP operation code.
+ */
+#define ARPOP_MAPOS_UNARP 23
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/arp/arp_oc.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/Makefile
===================================================================
--- network/uspace/srv/net/arp/Makefile (nonexistent)
+++ network/uspace/srv/net/arp/Makefile (revision 3846)
@@ -0,0 +1,84 @@
+#
+# Copyright (c) 2005 Martin Decky
+# 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 = arp
+
+## Setup toolchain
+#
+
+LIBC_PREFIX = ../../../lib/libc
+SOFTINT_PREFIX = ../../../lib/softint
+include $(LIBC_PREFIX)/Makefile.toolchain
+
+LIBS = $(LIBC_PREFIX)/libc.a
+
+## Sources
+#
+
+OUTPUT = $(NAME)
+SOURCES = \
+ $(NAME)_module.c \
+ $(NAME).c \
+ ../char_map.c \
+ ../measured_strings.c \
+ ../module.c \
+ ../modules.c \
+ ../packet.c
+
+DEFS += -D ARP_BUNDLE=1 -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
+
+OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
+
+.PHONY: all clean depend disasm
+
+all: $(OUTPUT) $(OUTPUT).disasm
+
+-include Makefile.depend
+
+clean:
+ -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend
+
+depend:
+ $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
+
+$(OUTPUT): $(OBJECTS) $(LIBS)
+ $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
+
+disasm: $(OUTPUT).disasm
+
+$(OUTPUT).disasm: $(OUTPUT)
+ $(OBJDUMP) -d $< >$@
+
+%.o: %.S
+ $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
+
+%.o: %.s
+ $(AS) $(AFLAGS) $< -o $@
+
+%.o: %.c
+ $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
/network/uspace/srv/net/arp/Makefile
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/arp/arp_module.h
===================================================================
--- network/uspace/srv/net/arp/arp_module.h (nonexistent)
+++ network/uspace/srv/net/arp/arp_module.h (revision 3846)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 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_MODULE_H__
+#define __NET_ARP_MODULE_H__
+
+#include <ipc/ipc.h>
+
+int arp_initialize( void );
+int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/arp/arp_module.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/networking/networking.c
===================================================================
--- network/uspace/srv/net/networking/networking.c (revision 3845)
+++ network/uspace/srv/net/networking/networking.c (revision 3846)
@@ -39,11 +39,10 @@
#include <malloc.h>
#include <stdio.h>
#include <task.h>
-//#include <thread.h>
#include <unistd.h>
+
#include <ipc/ipc.h>
#include <ipc/services.h>
-//#include <sys/mman.h>
#include "../char_map.h"
#include "../err.h"
@@ -53,15 +52,21 @@
#include "../modules.h"
//#include "../self_test.h"
-#include "../netif/netif_device_id_type.h"
+#include "../ip/ip_messages.h"
+#include "../netif/device.h"
-#ifdef NETWORKING_module
+#if IP_BUNDLE
- #include "../ip/ip.h"
- #include "../tcp/tcp.h"
+ #include "../ip/ip_module.h"
#endif
+#if TCP_BUNDLE
+
+ #include "../tcp/tcp_module.h"
+
+#endif
+
#define LO_NAME "lo"
#define LO_FILENAME "/sbin/lo"
#define DP8390_ISA_NAME "dp8390_isa"
@@ -99,16 +104,16 @@
struct netif{
/** A system-unique network interface identifier.
*/
- netif_device_id_t id;
+ device_id_t id;
/** A serving network interface driver module index.
*/
- module_ref driver_module;
+ module_ref driver;
/** A serving link layer module index.
*/
- module_ref link_layer_module;
+ module_ref nil;
/** A serving internet layer module index.
*/
- module_ref internet_layer_module;
+ module_ref il;
/** A system-unique network interface name.
*/
char * name;
@@ -138,7 +143,6 @@
static void client_connection( ipc_callid_t iid, ipc_call_t * icall );
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
int main( int argc, char * argv[] );
-int networking_call( ipc_callid_t callid );
int networking_initialize( void );
int networking_message( ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
//int parse_line( measured_strings_ref configuration, char * line );
@@ -146,7 +150,7 @@
int read_configuration( void );
task_id_t spawn( const char * fname );
int startup( void );
-netif_device_id_t generate_new_device_id( void );
+device_id_t generate_new_device_id( void );
static networking_globals_t networking_globals;
@@ -169,7 +173,7 @@
tmp_module->name = name;
tmp_module->filename = filename;
tmp_module->service = service;
- if( ERROR_OCCURED( modules_add( modules, tmp_module->name, tmp_module ))){
+ if( ERROR_OCCURED( modules_add( modules, tmp_module->name, 0, tmp_module ))){
free( tmp_module );
return ERROR_CODE;
}
@@ -183,7 +187,10 @@
ipcarg_t arg1, arg2, arg3;
int res;
- /* Accept the connection */
+ /*
+ * Accept the connection
+ * - Answer the first IPC_M_CONNECT_ME_TO call.
+ */
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( * icall ), icall->in_phone_hash, iid );
ipc_answer_0( iid, EOK );
@@ -195,51 +202,24 @@
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( call ), call.in_phone_hash, callid );
#ifdef NETWORKING_module
if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){
- res = ip_call( callid );
- if( res == EOK ){
- res = ip_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = ip_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
/* }else if( IS_NET_ARP_MESSAGE( call )){
- res = arp_call( callid );
- if( res == EOK ){
- res = arp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = arp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
*//* }else if( IS_NET_RARP_MESSAGE( call )){
- res = rarp_call( callid );
- if( res == EOK ){
- res = rarp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = rarp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
*//* }else if( IS_NET_ICMP_MESSAGE( call )){
- res = icmp_call( callid );
- if( res == EOK ){
- res = icmp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = icmp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
*//* }else if( IS_NET_UDP_MESSAGE( call )){
- res = udp_call( callid );
- if( res == EOK ){
- res = udp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = udp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
*/ }else if( IS_NET_TCP_MESSAGE( call )){
- res = tcp_call( callid );
- if( res == EOK ){
- res = tcp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = tcp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
/* }else if( IS_NET_SOCKET_MESSAGE( call )){
- res = socket_call( callid );
- if( res == EOK ){
- res = socket_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
-*//* }else if( IS_NET_LL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){
- res = ethernet_call( callid );
- if( res == EOK ){
- res = ethernet_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = socket_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
+*//* }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){
+ res = ethernet_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
*/ }else{
#endif
- res = networking_call( callid );
- if( res == EOK ){
- res = networking_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
- }
+ res = networking_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
#ifdef NETWORKING_module
}
#endif
@@ -248,13 +228,18 @@
}
int main( int argc, char * argv[] ){
+ ERROR_DECLARE;
+ ipcarg_t phonehash;
+
printf("\nTask %d - HelenOS Networking subsystem", task_get_id());
- return start_service( SERVICE_NETWORKING, NULL, NULL, client_connection, networking_initialize );
-}
+ async_set_client_connection( client_connection );
+ ERROR_PROPAGATE( networking_initialize());
+ ERROR_PROPAGATE( REGISTER_ME( SERVICE_NETWORKING, & phonehash ));
-int networking_call( ipc_callid_t callid ){
+ async_manager();
+
return EOK;
}
@@ -327,12 +312,12 @@
switch( method ){
case IPC_M_PHONE_HUNGUP:
return EOK;
- case NET_NETWORKING_DEVICE:
+ case NET_NET_DEVICE:
// TODO configure, register
// arg1 = netif id
printf( "\nNetworking: new netif %d", arg1 );
return EOK;
- case NET_NETWORKING_GET_DEVICE_CONFIGURATION:
+ case NET_NET_GET_DEVICE_CONF:
// arg1 = netif id
// arg2 = count
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, arg2 ));
@@ -343,9 +328,9 @@
configuration = NULL;
}
for( index = 0; index < arg2; ++ index ){
- setting = measured_strings_find( configuration, strings[ index ].value );
+ setting = measured_strings_find( configuration, strings[ index ].value, 0 );
if( ! setting ){
- setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value );
+ setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
}
if( setting ){
strings[ index ].length = setting->length;
@@ -360,11 +345,11 @@
ERROR_CODE = measured_strings_reply( strings, arg2 );
free( strings );
return ERROR_CODE;
- case NET_NETWORKING_GET_CONFIGURATION:
+ case NET_NET_GET_CONF:
// arg1 = count
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, arg1 ));
for( index = 0; index < arg1; ++ index ){
- setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value );
+ setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
if( setting ){
strings[ index ].length = setting->length;
strings[ index ].value = setting->value;
@@ -378,7 +363,7 @@
ERROR_CODE = measured_strings_reply( strings, arg1 );
free( strings );
return ERROR_CODE;
- case NET_NETWORKING_STARTUP:
+ case NET_NET_STARTUP:
return startup();
}
return ENOTSUP;
@@ -423,7 +408,7 @@
setting = measured_string_create_bulk( value, -1 );
if( ! setting ) return ENOMEM;
// add the configuration setting
- if( ERROR_OCCURED( measured_strings_add( configuration, name, setting ))){
+ if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
@@ -439,7 +424,7 @@
setting = measured_string_create_bulk( value, 0 );
if( ! setting ) return ENOMEM;
// add the configuration setting
- if( ERROR_OCCURED( measured_strings_add( configuration, name, setting ))){
+ if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
@@ -446,7 +431,7 @@
return EOK;
}
-netif_device_id_t generate_new_device_id( void ){
+device_id_t generate_new_device_id( void ){
return netifs_count( & networking_globals.netifs ) + 1;
}
@@ -482,7 +467,7 @@
}
// mandatory name
// printf( "\n\tname" );
- setting = measured_strings_find( & netif->configuration, "NAME" );
+ setting = measured_strings_find( & netif->configuration, "NAME", 0 );
if( ! setting ){
measured_strings_destroy( & netif->configuration );
free( netif );
@@ -492,7 +477,7 @@
// printf( " %s OK", netif->name );
// mandatory netif
// printf( "\n\tnetif" );
- setting = measured_strings_find( & netif->configuration, "NETIF" );
+ setting = measured_strings_find( & netif->configuration, "NETIF", 0 );
if( ! setting ){
// printf( " unknown" );
measured_strings_destroy( & netif->configuration );
@@ -500,8 +485,8 @@
return EINVAL;
}
// printf( " find %s in %d?", setting->value, modules_count( & networking_globals.modules ));
- netif->driver_module = modules_find( & networking_globals.modules, setting->value );
- if( ! netif->driver_module ){
+ netif->driver = modules_find( & networking_globals.modules, setting->value, 0 );
+ if( ! netif->driver ){
// printf( " not found" );
// TODO register the unknown one
measured_strings_destroy( & netif->configuration );
@@ -509,9 +494,9 @@
return EINVAL;
}
// printf( " found" );
- if( ! netif->driver_module->task_id ){
- netif->driver_module->task_id = spawn( netif->driver_module->filename );
- if( ! netif->driver_module->task_id ){
+ if( ! netif->driver->task_id ){
+ netif->driver->task_id = spawn( netif->driver->filename );
+ if( ! netif->driver->task_id ){
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
@@ -520,20 +505,20 @@
// printf( " OK" );
// optional link layer
// printf( "\n\tlink layer" );
- setting = measured_strings_find( & netif->configuration, "LL" );
+ setting = measured_strings_find( & netif->configuration, "NIL", 0 );
if( setting ){
- netif->link_layer_module = modules_find( & networking_globals.modules, setting->value );
- if( ! netif->link_layer_module ){
+ netif->nil = modules_find( & networking_globals.modules, setting->value, 0 );
+ if( ! netif->nil ){
// TODO register the unknown one
- -- netif->driver_module->usage;
+ -- netif->driver->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
- if( ! netif->link_layer_module->task_id ){
- netif->link_layer_module->task_id = spawn( netif->link_layer_module->filename );
- if( ! netif->link_layer_module->task_id ){
- -- netif->driver_module->usage;
+ if( ! netif->nil->task_id ){
+ netif->nil->task_id = spawn( netif->nil->filename );
+ if( ! netif->nil->task_id ){
+ -- netif->driver->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
@@ -540,34 +525,34 @@
}
}
}else{
- netif->link_layer_module = NULL;
+ netif->nil = NULL;
}
// mandatory internet layer
// printf( "\n\tinternet layer" );
- setting = measured_strings_find( & netif->configuration, "IL" );
+ setting = measured_strings_find( & netif->configuration, "IL", 0 );
if( ! setting ){
- -- netif->driver_module->usage;
- -- netif->link_layer_module->usage;
+ -- netif->driver->usage;
+ -- netif->nil->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
// printf( " set %s", setting->value );
- netif->internet_layer_module = modules_find( & networking_globals.modules, setting->value );
- if( ! netif->internet_layer_module ){
+ netif->il = modules_find( & networking_globals.modules, setting->value, 0 );
+ if( ! netif->il ){
// TODO register the unknown one
- -- netif->driver_module->usage;
- -- netif->link_layer_module->usage;
+ -- netif->driver->usage;
+ -- netif->nil->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
}
// printf( " found" );
- if( ! netif->internet_layer_module->task_id ){
- netif->internet_layer_module->task_id = spawn( netif->internet_layer_module->filename );
- if( ! netif->internet_layer_module->task_id ){
- -- netif->driver_module->usage;
- -- netif->link_layer_module->usage;
+ if( ! netif->il->task_id ){
+ netif->il->task_id = spawn( netif->il->filename );
+ if( ! netif->il->task_id ){
+ -- netif->driver->usage;
+ -- netif->nil->usage;
measured_strings_destroy( & netif->configuration );
free( netif );
return EINVAL;
@@ -578,7 +563,7 @@
free( netif );
return ERROR_CODE;
}
- if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, index ))){
+ if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){
netifs_exclude_index( & networking_globals.netifs, index );
return ERROR_CODE;
}
@@ -585,32 +570,35 @@
// printf( "\nloopback OK" );
// end of the static loopback initialization
// startup the loopback interface
- if( ! netif->driver_module->phone ){
+ if( ! netif->driver->phone ){
// printf( " connect?" );
- netif->driver_module->phone = connect_to_service( netif->driver_module->service );
+ netif->driver->phone = connect_to_service( netif->driver->service );
}
// printf( " connected" );
- ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_PROBE, netif->id ));
- ++ netif->driver_module->usage;
- if( netif->link_layer_module ){
- if( ! netif->link_layer_module->phone ){
- netif->link_layer_module->phone = connect_to_service( netif->link_layer_module->service );
+ // TODO io, irq
+ ERROR_PROPAGATE( async_req_3_0( netif->driver->phone, NET_NETIF_PROBE, netif->id, 0, 0 ));
+ ++ netif->driver->usage;
+ if( netif->nil ){
+ if( ! netif->nil->phone ){
+ netif->nil->phone = connect_to_service( netif->nil->service );
}
- ERROR_PROPAGATE( async_req_2_0( netif->link_layer_module->phone, NET_LL_DEVICE, netif->id, netif->driver_module->service ));
- ++ netif->link_layer_module->usage;
- internet_service = netif->link_layer_module->service;
+ ERROR_PROPAGATE( async_req_2_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, netif->driver->service ));
+ ++ netif->nil->usage;
+ internet_service = netif->nil->service;
// printf( " OK" );
}else{
- internet_service = netif->driver_module->service;
+ internet_service = netif->driver->service;
// printf( " none" );
}
- if( ! netif->internet_layer_module->phone ){
+ if( ! netif->il->phone ){
// printf( " connect" );
- netif->internet_layer_module->phone = connect_to_service( netif->internet_layer_module->service );
+ netif->il->phone = connect_to_service( netif->il->service );
}
- ERROR_PROPAGATE( async_req_2_0( netif->internet_layer_module->phone, NET_IL_DEVICE, netif->id, internet_service ));
- ++ netif->internet_layer_module->usage;
- ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_START, netif->id ));
+ // TODO IL_BUNDLE
+ ERROR_PROPAGATE( async_req_2_0( netif->il->phone, NET_IL_DEVICE, netif->id, internet_service ));
+ ++ netif->il->usage;
+ // TODO startup?
+ ERROR_PROPAGATE( async_req_1_0( netif->driver->phone, NET_NETIF_START, netif->id ));
// printf( "\n LO OK" );
return EOK;
}
/branches/network/uspace/srv/net/networking/Makefile
47,13 → 47,17
../modules.c
# ../self_test.c
 
DEFS += -D NETWORKING_$(NETWORKING)
 
ifeq ($(NETWORKING), module)
 
SOURCES += ../ip/ip.c \
../tcp/tcp.c
 
DEFS += -D IP_BUNDLE=1 -D TCP_BUNDLE=1
 
endif
 
DEFS += -D NETWORKING_$(NETWORKING)
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
.PHONY: all clean depend disasm
/branches/network/uspace/srv/net/packet.c
33,10 → 33,126
/** @file
*/
 
#include <errno.h>
#include <unistd.h>
#include <string.h>
 
#include <ipc/ipc.h>
#include <sys/mman.h>
 
#include "err.h"
 
#include "packet.h"
 
#define PACKET_MAGIC_VALUE 0x11227788
 
struct packet{
void * start;
size_t length;
size_t length;
size_t max_prefix;
size_t max_content;
size_t data_start;
size_t data_end;
int magic_value;
};
 
int packet_is_valid( packet_t packet );
 
packet_t packet_create( size_t max_prefix, size_t max_content, size_t max_sufix ){
size_t length;
packet_t packet;
 
length = max_prefix + max_content + max_sufix;
packet = ( packet_t ) mmap( NULL, sizeof( struct packet ) + length, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0 );
if( packet == MAP_FAILED ) return NULL;
packet->length = length;
packet->max_prefix = max_prefix;
packet->max_content = max_content;
packet->data_start = sizeof( struct packet ) + packet->max_prefix;
packet->data_end = packet->data_start;
packet->magic_value = PACKET_MAGIC_VALUE;
return packet;
}
 
int packet_is_valid( packet_t packet ){
return packet && ( packet->magic_value == PACKET_MAGIC_VALUE );
}
 
packet_t packet_copy( packet_t packet ){
packet_t new;
 
if( ! packet_is_valid( packet )) return NULL;
new = ( packet_t ) mmap( NULL, packet->length, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0 );
if( new == MAP_FAILED ) return NULL;
memcpy( new, packet, packet->length );
return new;
}
 
int packet_copy_data( packet_t packet, void * data, size_t length ){
if( ! packet_is_valid( packet )) return EINVAL;
if( packet->data_start + length >= (( size_t ) packet ) + packet->length ) return ENOMEM;
memcpy( packet + packet->data_start, data, length );
if( packet->data_start + length > packet->data_end ){
packet->data_end = packet->data_start + length;
}
return EOK;
}
 
void * packet_prepend( packet_t packet, size_t length ){
if(( ! packet_is_valid( packet )) || ( packet->data_start - sizeof( struct packet ) < length )) return NULL;
packet->data_start -= length;
return packet + packet->data_start;
}
 
void * packet_append( packet_t packet, size_t length ){
if(( ! packet_is_valid( packet )) || ( packet->data_end + length >= (( size_t ) packet ) + packet->length )) return NULL;
packet->data_end += length;
return packet + packet->data_end - length;
}
 
int packet_trim( packet_t packet, size_t prefix, size_t sufix ){
if(( ! packet_is_valid( packet )) || ( prefix + sufix > packet->data_end - packet->data_start )) return EINVAL;
packet->data_start += prefix;
packet->data_end -= sufix;
return EOK;
}
 
int packet_send( packet_t packet, int phone ){
if( ! packet_is_valid( packet )) return EINVAL;
return ipc_share_out_start( phone, packet, PROTO_READ | PROTO_WRITE );
}
 
int packet_receive( packet_ref packet ){
ERROR_DECLARE;
 
ipc_callid_t callid;
size_t size;
int flags;
 
if( ! packet ) return EINVAL;
if( ! ipc_share_out_receive( & callid, & size, & flags )) return EINVAL;
* packet = ( packet_t ) as_get_mappable_page( size );
if( !( * packet )) return ENOMEM;
if( ERROR_OCCURED( ipc_share_out_finalize( callid, * packet ))){
munmap( * packet, size );
return ERROR_CODE;
}
return EOK;
}
 
int packet_destroy( packet_t packet ){
if( ! packet_is_valid( packet )) return EINVAL;
return munmap( packet, sizeof( struct packet ) + packet->length );
}
 
size_t packet_get_data_length( packet_t packet ){
if( ! packet_is_valid( packet )) return 0;
return packet->data_end - packet->data_start;
}
 
void * packet_get_data( packet_t packet ){
if( ! packet_is_valid( packet )) return NULL;
return packet + packet->data_start;
}
 
/** @}
*/
/branches/network/uspace/srv/net/char_map.c
27,10 → 27,11
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
* A&nbsp;character string to integer map implementation file.
*/
 
#include <errno.h>
40,21 → 41,48
 
#include "char_map.h"
 
/** An&nbsp;internal magic value for a&nbsp;consistency check.
*/
#define CHAR_MAP_MAGIC_VALUE 0x12345611
 
int char_map_add_item( char_map_ref map, const char * identifier, const int value );
char_map_ref char_map_find_node( char_map_ref map, const char * identifier );
int char_map_is_valid( char_map_ref map );
/** Adds the value with the key to the map.
* Creates new nodes to map the key.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns ENOMEM if there is no memory left.
* @returns EEXIST if the key character string is already used.
*/
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value );
 
int char_map_add( char_map_ref map, const char * identifier, const int value ){
if( char_map_is_valid( map ) && ( * identifier )){
/** Returns the node assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @returns The node holding the integral value assigned to the key character string.
* @returns NULL if the key is not assigned a&nbsp;node.
*/
char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, const size_t length );
 
/** Checks if the map is valid.
* @param map The character string to integer map. Input parameter.
* @returns TRUE if the map is valid.
* @returns FALSE otherwise.
*/
int char_map_is_valid( const char_map_ref map );
 
int char_map_add( char_map_ref map, const char * identifier, size_t length, const int value ){
if( char_map_is_valid( map ) && ( identifier ) && (( length ) || ( * identifier ))){
int index;
 
for( index = 0; index < map->next; ++ index ){
if( map->items[ index ]->c == * identifier ){
++ identifier;
if( * identifier ){
return char_map_add( map->items[ index ], identifier, value );
if( length ) -- length;
if( length || ( * identifier )){
return char_map_add( map->items[ index ], identifier, length, value );
}else{
if( map->items[ index ]->value != CHAR_MAP_NULL ) return EEXISTS;
map->items[ index ]->value = value;
62,12 → 90,12
}
}
}
return char_map_add_item( map, identifier, value );
return char_map_add_item( map, identifier, length, value );
}
return EINVAL;
}
 
int char_map_add_item( char_map_ref map, const char * identifier, const int value ){
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value ){
if( map->next == ( map->size - 1 )){
char_map_ref * tmp;
 
83,13 → 111,14
char_map_initialize( map->items[ map->next ] );
map->items[ map->next ]->c = * identifier;
++ identifier;
if( * identifier ){
map->items[ map->next ]->value = CHAR_MAP_NULL;
char_map_add_item( map->items[ map->next ], identifier, value );
if( length ) -- length;
++ map->next;
if( length || ( * identifier )){
map->items[ map->next - 1 ]->value = CHAR_MAP_NULL;
return char_map_add_item( map->items[ map->next - 1 ], identifier, length, value );
}else{
map->items[ map->next ]->value = value;
map->items[ map->next - 1 ]->value = value;
}
++ map->next;
return EOK;
}
 
105,10 → 134,10
}
}
 
int char_map_exclude( char_map_ref map, const char * identifier ){
int char_map_exclude( char_map_ref map, const char * identifier, size_t length ){
char_map_ref node;
 
node = char_map_find_node( map, identifier );
node = char_map_find_node( map, identifier, length );
if( node ){
int value;
 
119,22 → 148,23
return CHAR_MAP_NULL;
}
 
int char_map_find( char_map_ref map, const char * identifier ){
int char_map_find( const char_map_ref map, const char * identifier, size_t length ){
char_map_ref node;
 
node = char_map_find_node( map, identifier );
node = char_map_find_node( map, identifier, length );
return node ? node->value : CHAR_MAP_NULL;
}
 
char_map_ref char_map_find_node( char_map_ref map, const char * identifier ){
char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, size_t length ){
if( ! char_map_is_valid( map )) return NULL;
if( * identifier ){
if( length ) -- length;
if( length || ( * identifier )){
int index;
 
for( index = 0; index < map->next; ++ index ){
if( map->items[ index ]->c == * identifier ){
++ identifier;
return char_map_find_node( map->items[ index ], identifier );
return char_map_find_node( map->items[ index ], identifier, length );
}
}
return NULL;
142,7 → 172,7
return map;
}
 
int char_map_get_value( char_map_ref map ){
int char_map_get_value( const char_map_ref map ){
return char_map_is_valid( map ) ? map->value : CHAR_MAP_NULL;
}
 
159,20 → 189,20
return EOK;
}
 
int char_map_is_valid( char_map_ref map ){
int char_map_is_valid( const char_map_ref map ){
return map && ( map->magic == CHAR_MAP_MAGIC_VALUE );
}
 
int char_map_update( char_map_ref map, const char * identifier, const int value ){
int char_map_update( char_map_ref map, const char * identifier, const size_t length, const int value ){
char_map_ref node;
 
// if( ! char_map_is_valid( map )) return EINVAL;
node = char_map_find_node( map, identifier );
node = char_map_find_node( map, identifier, length );
if( node ){
node->value = value;
return EOK;
}else{
return char_map_add( map, identifier, value );
return char_map_add( map, identifier, length, value );
}
}
 
/branches/network/uspace/srv/net/generic_char_map.h
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
44,91 → 44,91
 
#define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622
 
#define GENERIC_CHAR_MAP_DECLARE( name, type ) \
\
GENERIC_FIELD_DECLARE( name##_items, type ) \
\
typedef struct name name##_t; \
typedef name##_t * name##_ref; \
\
struct name{ \
char_map_t names; \
name##_items_t values; \
int magic; \
}; \
\
int name##_add( name##_ref map, const char * name, type * value ); \
int name##_count( name##_ref map ); \
void name##_destroy( name##_ref map ); \
void name##_exclude( name##_ref map, const char * name ); \
type * name##_find( name##_ref map, const char * name ); \
type * name##_get_index( name##_ref map, int index ); \
int name##_initialize( name##_ref map ); \
#define GENERIC_CHAR_MAP_DECLARE( name, type ) \
\
GENERIC_FIELD_DECLARE( name##_items, type ) \
\
typedef struct name name##_t; \
typedef name##_t * name##_ref; \
\
struct name{ \
char_map_t names; \
name##_items_t values; \
int magic; \
}; \
\
int name##_add( name##_ref map, const char * name, const size_t length, type * value ); \
int name##_count( name##_ref map ); \
void name##_destroy( name##_ref map ); \
void name##_exclude( name##_ref map, const char * name, const size_t length ); \
type * name##_find( name##_ref map, const char * name, const size_t length ); \
type * name##_get_index( name##_ref map, int index ); \
int name##_initialize( name##_ref map ); \
int name##_is_valid( name##_ref map );
 
 
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \
\
GENERIC_FIELD_IMPLEMENT( name##_items, type ) \
\
int name##_add( name##_ref map, const char * name, type * value ){ \
ERROR_DECLARE; \
int index; \
\
if( ! name##_is_valid( map )) return EINVAL; \
index = name##_items_add( & map->values, value ); \
if( index < 0 ) return index; \
if( ERROR_OCCURED( char_map_add( & map->names, name, index ))){ \
name##_items_exclude_index( & map->values, index ); \
return ERROR_CODE; \
} \
return EOK; \
} \
\
int name##_count( name##_ref map ){ \
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \
\
GENERIC_FIELD_IMPLEMENT( name##_items, type ) \
\
int name##_add( name##_ref map, const char * name, const size_t length, type * value ){ \
ERROR_DECLARE; \
\
int index; \
\
if( ! name##_is_valid( map )) return EINVAL; \
index = name##_items_add( & map->values, value ); \
if( index < 0 ) return index; \
if( ERROR_OCCURED( char_map_add( & map->names, name, length, index ))){ \
name##_items_exclude_index( & map->values, index ); \
return ERROR_CODE; \
} \
return EOK; \
} \
\
int name##_count( name##_ref map ){ \
return name##_is_valid( map ) ? name##_items_count( & map->values ) : -1; \
} \
\
void name##_destroy( name##_ref map ){ \
if( name##_is_valid( map )){ \
char_map_destroy( & map->names ); \
name##_items_destroy( & map->values ); \
} \
} \
\
void name##_exclude( name##_ref map, const char * name ){ \
if( name##_is_valid( map )){ \
int index; \
\
index = char_map_exclude( & map->names, name ); \
if( index != CHAR_MAP_NULL ){ \
name##_items_exclude_index( & map->values, index ); \
} \
} \
} \
\
type * name##_find( name##_ref map, const char * name ){ \
if( name##_is_valid( map )){ \
int index; \
\
index = char_map_find( & map->names, name ); \
if( index != CHAR_MAP_NULL ){ \
return name##_items_get_index( & map->values, index ); \
} \
} \
return NULL; \
} \
\
int name##_initialize( name##_ref map ){ \
if( ! map ) return EINVAL; \
char_map_initialize( & map->names ); \
name##_items_initialize( & map->values ); \
map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
return EOK; \
} \
\
int name##_is_valid( name##_ref map ){ \
return map && ( map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE ); \
} \
\
void name##_destroy( name##_ref map ){ \
if( name##_is_valid( map )){ \
char_map_destroy( & map->names ); \
name##_items_destroy( & map->values ); \
} \
} \
\
void name##_exclude( name##_ref map, const char * name, const size_t length ){ \
if( name##_is_valid( map )){ \
int index; \
\
index = char_map_exclude( & map->names, name, length ); \
if( index != CHAR_MAP_NULL ){ \
name##_items_exclude_index( & map->values, index ); \
} \
} \
} \
\
type * name##_find( name##_ref map, const char * name, const size_t length ){ \
if( name##_is_valid( map )){ \
int index; \
\
index = char_map_find( & map->names, name, length ); \
if( index != CHAR_MAP_NULL ){ \
return name##_items_get_index( & map->values, index ); \
} \
} \
return NULL; \
} \
\
int name##_initialize( name##_ref map ){ \
if( ! map ) return EINVAL; \
char_map_initialize( & map->names ); \
name##_items_initialize( & map->values ); \
map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
return EOK; \
} \
\
int name##_is_valid( name##_ref map ){ \
return map && ( map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE ); \
}
 
#endif
/branches/network/uspace/srv/net/packet.h
33,7 → 33,30
/** @file
*/
 
typedef struct packet * packet_t;
#ifndef __NET_PACKET_H__
#define __NET_PACKET_H__
 
#define PACKET_PREPEND( packet, type ) ( type * ) packet_prepend(( packet ), sizeof( type ))
#define PACKET_APPEND( packet, type ) ( type * ) packet_append(( packet ), sizeof( type ))
#define PACKET_TRIM( packet, prefix, sufix ) packet_trim(( packet ), sizeof( prefix ), sizeof( sufix ))
 
typedef struct packet * packet_t;
typedef packet_t * packet_ref;
 
packet_t packet_create( size_t max_prefix, size_t max_content, size_t max_sufix );
void * packet_prepend( packet_t packet, size_t length );
void * packet_append( packet_t packet, size_t length );
packet_t packet_copy( packet_t packet );
int packet_copy_data( packet_t packet, void * data, size_t length );
// TODO protocol identification?
int packet_send( packet_t packet, int phone );
int packet_receive( packet_ref packet );
int packet_trim( packet_t packet, size_t prefix, size_t sufix );
int packet_destroy( packet_t packet );
size_t packet_get_data_length( packet_t packet );
void * packet_get_data( packet_t packet );
 
#endif
 
/** @}
*/
/branches/network/uspace/srv/net/char_map.h
31,33 → 31,124
*/
 
/** @file
* A&nbsp;character string to integer map header file.
*/
 
#ifndef __CHAR_MAP_H__
#define __CHAR_MAP_H__
 
/** An&nbsp;invalid assigned value used also if an&nbsp;entry does not exist.
*/
#define CHAR_MAP_NULL ( -1 )
 
/** A&nbsp;type definition of a&nbsp;character string to integer map.
* @see char_map
*/
typedef struct char_map char_map_t;
 
/** A&nbsp;type definition of a&nbsp;character string to integer map pointer.
* @see char_map
*/
typedef char_map_t * char_map_ref;
 
/** A&nbsp;character string to integer map item.
* This structure recursivelly contains itself as a&nbsp;character by character tree.
* The actually mapped character string consists o fall the parent characters and the actual one.
*/
struct char_map{
char c;
int value;
int size;
int next;
 
/** An actually mapped character.
*/
char c;
 
/** A&nbsp;stored integral value.
*/
int value;
 
/** A&nbsp;next character array size.
*/
int size;
 
/** The first free position in the next character array.
*/
int next;
 
/** The next character array.
*/
char_map_ref * items;
int magic;
 
/** The consistency check magic value.
*/
int magic;
};
 
int char_map_add( char_map_ref map, const char * identifier, const int value );
/** Adds the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/
int char_map_add( char_map_ref map, const char * identifier, size_t length, const int value );
 
/** Clears and destroys the map.
* @param map The character string to integer map. Input/output parameter.
*/
void char_map_destroy( char_map_ref map );
int char_map_exclude( char_map_ref map, const char * identifier );
int char_map_find( char_map_ref map, const char * identifier );
int char_map_get_value( char_map_ref map );
 
/** Excludes the value assigned to the key from the map.
* The entry is cleared from the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
int char_map_exclude( char_map_ref map, const char * identifier, size_t length );
 
/** Returns the value assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
int char_map_find( const char_map_ref map, const char * identifier, size_t length );
 
/** Returns the value assigned to the map.
* @param map The character string to integer map. Input parameter.
* @returns The integral value assigned to the map.
* @returns CHAR_MAP_NULL if the map is not assigned a&nbsp;value.
*/
int char_map_get_value( const char_map_ref map );
 
/** Initializes the map.
* @param map The character string to integer map. Input/output parameter.
* @returns EOK on success.
* @returns EINVAL if the map parameter is NULL.
* @returns ENOMEM if there is no memory left.
*/
int char_map_initialize( char_map_ref map );
int char_map_update( char_map_ref map, const char * identifier, const int value );
 
/** Adds or updates the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/
int char_map_update( char_map_ref map, const char * identifier, size_t length, const int value );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/netif/netif_device_id_type.h
File deleted
Property changes:
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: network/uspace/srv/net/netif/device.h
===================================================================
--- network/uspace/srv/net/netif/device.h (nonexistent)
+++ network/uspace/srv/net/netif/device.h (revision 3846)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2008 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 "../int_map.h"
+
+#ifndef __NET_DEVICE_ID_TYPE_H__
+#define __NET_DEVICE_ID_TYPE_H__
+
+#define DEVICE_MAP_DECLARE INT_MAP_DECLARE
+#define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT
+
+typedef int device_id_t;
+
+typedef enum device_state device_state_t;
+
+typedef struct device_stats device_stats_t;
+typedef device_stats_t * device_stats_ref;
+
+enum device_state{
+ NETIF_NULL = 0,
+ NETIF_STOPPED,
+ NETIF_ACTIVE,
+ NETIF_CARRIER_LOST
+};
+
+// based on linux_kernel/include/linux/netdevice.h
+
+struct device_stats{
+ unsigned long rx_packets; /* total packets received */
+ unsigned long tx_packets; /* total packets transmitted */
+ unsigned long rx_bytes; /* total bytes received */
+ unsigned long tx_bytes; /* total bytes transmitted */
+ unsigned long rx_errors; /* bad packets received */
+ unsigned long tx_errors; /* packet transmit problems */
+ unsigned long rx_dropped; /* no space in linux buffers */
+ unsigned long tx_dropped; /* no space available in linux */
+ unsigned long multicast; /* multicast packets received */
+ unsigned long collisions;
+
+ /* detailed rx_errors: */
+ unsigned long rx_length_errors;
+ unsigned long rx_over_errors; /* receiver ring buff overflow */
+ unsigned long rx_crc_errors; /* recved pkt with crc error */
+ unsigned long rx_frame_errors; /* recv'd frame alignment error */
+ unsigned long rx_fifo_errors; /* recv'r fifo overrun */
+ unsigned long rx_missed_errors; /* receiver missed packet */
+
+ /* detailed tx_errors */
+ unsigned long tx_aborted_errors;
+ unsigned long tx_carrier_errors;
+ unsigned long tx_fifo_errors;
+ unsigned long tx_heartbeat_errors;
+ unsigned long tx_window_errors;
+
+ /* for cslip etc */
+ unsigned long rx_compressed;
+ unsigned long tx_compressed;
+};
+
+#endif
+
+/** @}
+ */
+
/network/uspace/srv/net/netif/device.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: network/uspace/srv/net/netif/netif.c
===================================================================
--- network/uspace/srv/net/netif/netif.c (revision 3845)
+++ network/uspace/srv/net/netif/netif.c (revision 3846)
@@ -35,6 +35,7 @@
#include <async.h>
#include <stdio.h>
+
#include <ipc/ipc.h>
#include <ipc/services.h>
//#include <sys/mman.h>
@@ -42,36 +43,53 @@
#include "../err.h"
#include "../messages.h"
#include "../modules.h"
+#include "../packet.h"
+#include "device.h"
#include "netif.h"
-#include "netif_device_id_type.h"
+#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
+#define IPC_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call )
+#define IPC_GET_IO( call ) ( int ) IPC_GET_ARG3( * call )
+#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call )
+
extern netif_globals_t netif_globals;
-extern int netif_initialize( void );
-extern void netif_print_name( void );
-extern int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
-extern int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
-extern int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
-extern int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
-extern int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
+extern int initialize( void );
+extern int probe_auto_message( void );
+extern int probe_message( device_id_t device_id, int irq, int io );
+extern int send_message( device_id_t device_id, packet_t packet );
+extern int start_message( device_id_t device_id );
+extern int stop_message( device_id_t device_id );
-DEVICE_MAP_IMPLEMENT( netif_device_map, netif_device_t )
+DEVICE_MAP_IMPLEMENT( device_map, device_t )
-int netif_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
-int netif_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
+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 get_device_stats( device_id_t device_id, device_stats_ref * stats );
-int netif_device_find( netif_device_id_t device_id, netif_device_ref * device ){
- * device = netif_device_map_find( & netif_globals.netif_device_map, device_id );
+int find_device( device_id_t device_id, device_ref * device ){
+ * device = device_map_find( & netif_globals.device_map, device_id );
if( ! * device ) return ENOENT;
if(( ** device ).state == NETIF_NULL ) return EPERM;
return EOK;
}
-void netif_device_stats_null( netif_device_stats_ref stats )
-{
- //memset( stats, 0, sizeof( netif_device_t ));
- stats->rx_packets = 0;
+int get_device_stats( device_id_t device_id, device_stats_ref * stats ){
+ ERROR_DECLARE;
+
+ device_ref device;
+
+ if( ! stats ) return EINVAL;
+ ERROR_PROPAGATE( find_device( device_id, & device ));
+ * stats = & device->stats;
+ return EOK;
+}
+
+void null_device_stats( device_stats_ref stats ){
+ memset( stats, 0, sizeof( device_stats_t ));
+/* stats->rx_packets = 0;
stats->tx_packets = 0;
stats->rx_bytes = 0;
stats->tx_bytes = 0;
@@ -94,58 +112,65 @@
stats->tx_window_errors = 0;
stats->rx_compressed = 0;
stats->tx_compressed = 0;
+*/
}
-int netif_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
+int register_message( device_id_t device_id, int phone ){
ERROR_DECLARE;
+ device_ref device;
+
+ ERROR_PROPAGATE( find_device( device_id, & device ));
+ if( device->nil_phone ) return ELIMIT;
+ device->nil_phone = phone;
+ return EOK;
+}
+
+int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+ ERROR_DECLARE;
+
size_t length;
- netif_device_ref device;
+ device_stats_ref stats;
+ packet_t packet;
// printf( "\nNETIF message %d", method );
- switch( method ){
+ * answer_count = 0;
+ switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_NETIF_PROBE_AUTO:
- return netif_probe_auto_message( arg1, arg2, arg3, result1, result2, result3 );
+ return probe_auto_message();
case NET_NETIF_PROBE:
- return netif_probe_message( arg1, arg2, arg3, result1, result2, result3 );
- case NET_NETIF_REGISTER:
- case NET_LL_REGISTER:
- ERROR_PROPAGATE( netif_device_find( arg1, & device ));
- device->ll_registered = connect_to_service( arg2 );
- return EOK;
+ return probe_message( IPC_GET_DEVICE( call ), IPC_GET_IRQ( call ), IPC_GET_IO( call ));
+ case IPC_M_CONNECT_TO_ME:
+ return register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call ));
case NET_NETIF_SEND:
- return netif_send_message( arg1, arg2, arg3, result1, result2, result3 );
+ ERROR_PROPAGATE( packet_receive( & packet ));
+ return send_message( IPC_GET_DEVICE( call ), packet );
case NET_NETIF_START:
- return netif_start_message( arg1, arg2, arg3, result1, result2, result3 );
+ return start_message( IPC_GET_DEVICE( call ));
case NET_NETIF_STATS:
ERROR_PROPAGATE( ipc_data_read_receive( & callid, & length ));
- if( length < sizeof( netif_device_stats_t )){
- ipc_answer_0( callid, EOVERFLOW );
- return EOVERFLOW;
- }
- if( ERROR_OCCURED( netif_device_find( arg1, & device ))){
- ipc_answer_0( callid, ERROR_CODE );
- return ERROR_CODE;
- }
- return ipc_data_read_finalize( callid, & device->stats, sizeof( netif_device_stats_t ));
+ if( length < sizeof( device_stats_t )) return EOVERFLOW;
+ ERROR_PROPAGATE( get_device_stats( IPC_GET_DEVICE( call ), & stats ));
+ return ipc_data_read_finalize( callid, stats, sizeof( device_stats_t ));
case NET_NETIF_STOP:
- return netif_stop_message( arg1, arg2, arg3, result1, result2, result3 );
+ return stop_message( IPC_GET_DEVICE( call ));
}
return ENOTSUP;
}
-int netif_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){
- services_t need[ 2 ];
- int * need_phone[ 2 ];
+int netif_start_module( async_client_conn_t client_connection ){
+ ERROR_DECLARE;
- need[ 0 ] = SERVICE_NETWORKING;
- need[ 1 ] = NULL;
- need_phone[ 0 ] = & netif_globals.networking_phone;
- need_phone[ 1 ] = NULL;
- netif_device_map_initialize( & netif_globals.netif_device_map );
- return start_service( NULL, need, need_phone, client_connection, netif_initialize );
+ async_set_client_connection( client_connection );
+ netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
+ device_map_initialize( & netif_globals.device_map );
+ ERROR_PROPAGATE( initialize());
+
+ async_manager();
+
+ return EOK;
}
/** @}
/branches/network/uspace/srv/net/netif/lo.c
36,14 → 36,15
#include <async.h>
#include <errno.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
//#include <sys/mman.h>
 
#include "../err.h"
#include "../measured_strings.h"
#include "../messages.h"
#include "../modules.h"
#include "../packet.h"
 
#include "netif.h"
 
53,49 → 54,45
 
netif_globals_t netif_globals;
 
void change_state( netif_device_ref device, netif_state_t state );
int change_state_message( netif_device_id_t device_id, netif_state_t state );
int netif_create( netif_device_id_t device_id, netif_device_ref * device );
int netif_call( ipc_callid_t callid );
int netif_initialize( void );
int change_state_message( device_id_t device_id, device_state_t state );
int create( device_id_t device_id, device_ref * device );
int initialize( void );
void netif_print_name( void );
int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
int probe_auto_message( void );
int probe_message( device_id_t device_id, int irq, int io );
int send_message( device_id_t device_id, packet_t packet );
int start_message( device_id_t device_id );
int stop_message( device_id_t device_id );
 
void change_state( netif_device_ref device, netif_state_t state ){
device->state = state;
ll_message( device, NET_LL_DEVICE_STATE_CHANGED, device->state, NULL, NULL, NULL, NULL );
}
 
int change_state_message( netif_device_id_t device_id, netif_state_t state ){
int change_state_message( device_id_t device_id, device_state_t state ){
ERROR_DECLARE;
 
netif_device_ref device;
device_ref device;
 
ERROR_PROPAGATE( netif_device_find( device_id, & device ));
change_state( device, state );
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->state != state ){
device->state = state;
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL, NULL, NULL, NULL );
}
return EOK;
}
 
int netif_create( netif_device_id_t device_id, netif_device_ref * device ){
int create( device_id_t device_id, device_ref * device ){
ERROR_DECLARE;
 
if( netif_device_map_count( & netif_globals.netif_device_map ) > 0 ){
if( device_map_count( & netif_globals.device_map ) > 0 ){
return EXDEV;
}else{
* device = ( netif_device_ref ) malloc( sizeof( netif_device_t ));
* device = ( device_ref ) malloc( sizeof( device_t ));
if( !( * device )) return ENOMEM;
( ** device ).device_id = device_id;
( ** device ).ll_registered = -1;
( ** device ).nil_phone = -1;
( ** device ).specific = NULL;
netif_device_stats_null( &(( ** device ).stats ));
null_device_stats( &(( ** device ).stats ));
( ** device ).state = NETIF_STOPPED;
( ** device ).flags = NULL;
( ** device ).mtu = DEFAULT_MTU;
if( ERROR_OCCURED( netif_device_map_add( & netif_globals.netif_device_map, ( ** device ).device_id, * device ))){
if( ERROR_OCCURED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
free( * device );
* device = NULL;
return ERROR_CODE;
104,11 → 101,7
return EOK;
}
 
int netif_call( ipc_callid_t callid ){
return EOK;
}
 
int netif_initialize( void ){
int initialize( void ){
ipcarg_t phonehash;
 
return REGISTER_ME( SERVICE_LO, & phonehash );
118,20 → 111,20
printf( NAME );
}
 
int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
int probe_auto_message( void ){
/* ERROR_DECLARE;
 
netif_device_ref device;
device_ref device;
 
ERROR_PROPAGATE( netif_create( arg1, & device ));
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NETWORKING_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
ERROR_PROPAGATE( create( arg1, & device ));
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
*/ return ENOTSUP;
}
 
int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
int probe_message( device_id_t device_id, int irq, int io ){
ERROR_DECLARE;
 
netif_device_ref device;
device_ref device;
aid_t message;
ipc_call_t answer;
measured_string_t configuration[ 1 ] = {{ "MTU", 3 }};
140,9 → 133,9
char * data;
 
// create a new device
ERROR_PROPAGATE( netif_create( arg1, & device ));
ERROR_PROPAGATE( create( device_id, & device ));
// get configuration
message = async_send_2( netif_globals.networking_phone, NET_NETWORKING_GET_DEVICE_CONFIGURATION, device->device_id, count, & answer );
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_OCCURED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
|| ERROR_OCCURED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
156,7 → 149,7
device->mtu = DEFAULT_MTU;
}
// print the settings
printf("\n -MTU=%d", device->mtu );
printf("\n -MTU =\t%d", device->mtu );
free( settings );
free( data );
// end request
164,31 → 157,44
return EOK;
}
 
int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
int send_message( device_id_t device_id, packet_t packet ){
ERROR_DECLARE;
 
netif_device_ref device;
device_ref device;
size_t length;
aid_t message;
ipc_call_t answer;
ipcarg_t result;
packet_t received;
 
ERROR_PROPAGATE( netif_device_find( arg1, & device ));
if( device->state == NETIF_ACTIVE ){
++ device->stats.tx_packets;
++ device->stats.rx_packets;
// TODO packet size
//device->stats->tx_bytes += ;
//device->stats->rx_bytes += ;
ll_message( device, NET_LL_RECEIVED, arg2, NULL, NULL, NULL, NULL );
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->state != NETIF_ACTIVE ) return EPERM;
++ device->stats.tx_packets;
++ device->stats.rx_packets;
length = packet_get_data_length( packet );
device->stats.tx_bytes += length;
device->stats.rx_bytes += length;
received = packet_copy( packet );
packet_destroy( packet );
if( ! received ){
++ device->stats.rx_dropped;
return EOK;
}else{
return EPERM;
}
message = async_send_1( device->nil_phone, NET_NIL_RECEIVED, ( device_id ), & answer );
if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){
++ device->stats.rx_dropped;
}
async_wait_for( message, & result );
if( result != EOK ) ++ device->stats.rx_dropped;
return EOK;
}
 
int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
return change_state_message( arg1, NETIF_ACTIVE );
int start_message( device_id_t device_id ){
return change_state_message( device_id, NETIF_ACTIVE );
}
 
int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
return change_state_message( arg1, NETIF_STOPPED );
int stop_message( device_id_t device_id ){
return change_state_message( device_id, NETIF_STOPPED );
}
 
/** @}
/branches/network/uspace/srv/net/netif/netif.h
37,79 → 37,34
#ifndef __NET_NETIF_H__
#define __NET_NETIF_H__
 
#include "netif_device_id_type.h"
#include "device.h"
 
#define ll_message( device, message, arg2, arg3, result1, result2, result3 ) \
if(( device )->ll_registered >= 0 ) async_msg_3(( device )->ll_registered, ( message ), ( device )->device_id, arg2, arg3 )
#define nil_message( device, message, arg2, arg3, result1, result2, result3 ) \
if(( device )->nil_phone >= 0 ) async_msg_3(( device )->nil_phone, ( message ), ( device )->device_id, arg2, arg3 )
 
typedef enum netif_state netif_state_t;
typedef struct device device_t;
typedef device_t * device_ref;
typedef struct netif_globals netif_globals_t;
 
typedef struct netif_device_stats netif_device_stats_t;
typedef netif_device_stats_t * netif_device_stats_ref;
typedef struct netif_device netif_device_t;
typedef netif_device_t * netif_device_ref;
typedef struct netif_globals netif_globals_t;
DEVICE_MAP_DECLARE( device_map, device_t );
 
DEVICE_MAP_DECLARE( netif_device_map, netif_device_t );
 
enum netif_state{
NETIF_NULL = 0,
NETIF_STOPPED,
NETIF_ACTIVE,
NETIF_CARRIER_LOST
struct device{
device_id_t device_id;
int nil_phone;
device_stats_t stats;
device_state_t state;
int flags;
size_t mtu;
void * specific;
};
 
// based on linux_kernel/include/linux/netdevice.h
 
struct netif_device_stats{
unsigned long rx_packets; /* total packets received */
unsigned long tx_packets; /* total packets transmitted */
unsigned long rx_bytes; /* total bytes received */
unsigned long tx_bytes; /* total bytes transmitted */
unsigned long rx_errors; /* bad packets received */
unsigned long tx_errors; /* packet transmit problems */
unsigned long rx_dropped; /* no space in linux buffers */
unsigned long tx_dropped; /* no space available in linux */
unsigned long multicast; /* multicast packets received */
unsigned long collisions;
 
/* detailed rx_errors: */
unsigned long rx_length_errors;
unsigned long rx_over_errors; /* receiver ring buff overflow */
unsigned long rx_crc_errors; /* recved pkt with crc error */
unsigned long rx_frame_errors; /* recv'd frame alignment error */
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
unsigned long rx_missed_errors; /* receiver missed packet */
 
/* detailed tx_errors */
unsigned long tx_aborted_errors;
unsigned long tx_carrier_errors;
unsigned long tx_fifo_errors;
unsigned long tx_heartbeat_errors;
unsigned long tx_window_errors;
 
/* for cslip etc */
unsigned long rx_compressed;
unsigned long tx_compressed;
};
 
struct netif_device{
netif_device_id_t device_id;
int ll_registered;
netif_device_stats_t stats;
netif_state_t state;
int flags;
size_t mtu;
void * specific;
};
 
struct netif_globals{
int networking_phone;
netif_device_map_t netif_device_map;
int networking_phone;
device_map_t device_map;
};
 
int netif_device_find( netif_device_id_t device_id, netif_device_ref * device );
void netif_device_stats_null( netif_device_stats_ref stats );
int find_device( device_id_t device_id, device_ref * device );
void null_device_stats( device_stats_ref stats );
 
#endif
 
/branches/network/uspace/srv/net/netif/Makefile
45,9 → 45,10
$(NETIF).c \
../measured_strings.h \
../module.c \
../modules.c
../modules.c \
../packet.c
 
DEFS += -D NETWORKING_$(NETWORKING) -D $(NETIF)_call=module_call -D $(NETIF)_message=module_message -D $(NETIF)_start_module=module_start -D $(NETIF)_print_name=module_print_name
DEFS += -D $(NETIF)_message=module_message -D $(NETIF)_start_module=module_start -D $(NETIF)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
OBJECTS += $(addsuffix .o,$(basename $(OUTPUT)))
/branches/network/uspace/srv/net/self_test.c
48,13 → 48,13
 
#include "self_test.h"
 
#define TEST( name, function_call, result ); { \
#define TEST( name, function_call, result ); { \
printf( "\n\t%s", ( name )); \
if(( function_call ) != ( result )){ \
printf( "\tERROR" ); \
}else{ \
printf( "\tOK" ); \
} \
if(( function_call ) != ( result )){ \
printf( "\tERROR" ); \
}else{ \
printf( "\tOK" ); \
} \
}
 
#if NET_SELF_TEST_INT_MAP
97,39 → 97,39
char_map_t cm;
 
printf( "\nChar map test" );
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL );
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL );
TEST( "initialize", char_map_initialize( & cm ), EOK );
TEST( "get_value", char_map_get_value( & cm ), CHAR_MAP_NULL );
TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL );
TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL );
TEST( "add bla 1 eok", char_map_add( & cm, "bla", 1 ), EOK );
TEST( "find bla 1", char_map_find( & cm, "bla" ), 1 );
TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 10 ), EEXISTS );
TEST( "update bla 2 eok", char_map_update( & cm, "bla", 2 ), EOK );
TEST( "find bla 2", char_map_find( & cm, "bla" ), 2 );
TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 2 ), EOK );
TEST( "exclude bla 2", char_map_exclude( & cm, "bla" ), 2 );
TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL );
TEST( "find ucho 2", char_map_find( & cm, "ucho" ), 2 );
TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 3 ), EOK );
TEST( "find ucho 3", char_map_find( & cm, "ucho" ), 3 );
TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 5 ), EOK );
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
TEST( "add bla 6 eok", char_map_add( & cm, "bla", 6 ), EOK );
TEST( "find bla 6", char_map_find( & cm, "bla" ), 6 );
TEST( "exclude bla 6", char_map_exclude( & cm, "bla" ), 6 );
TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL );
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
TEST( "add auto 7 eok", char_map_add( & cm, "auto", 7 ), EOK );
TEST( "find auto 7", char_map_find( & cm, "auto" ), 7 );
TEST( "add kara 8 eok", char_map_add( & cm, "kara", 8 ), EOK );
TEST( "find kara 8", char_map_find( & cm, "kara" ), 8 );
TEST( "add nic 9 eok", char_map_add( & cm, "nic", 9 ), EOK );
TEST( "find nic 9", char_map_find( & cm, "nic" ), 9 );
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL );
TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL );
TEST( "add bla 1 eok", char_map_add( & cm, "bla", 0, 1 ), EOK );
TEST( "find bla 1", char_map_find( & cm, "bla", 0 ), 1 );
TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 0, 10 ), EEXISTS );
TEST( "update bla 2 eok", char_map_update( & cm, "bla", 0, 2 ), EOK );
TEST( "find bla 2", char_map_find( & cm, "bla", 0 ), 2 );
TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 0, 2 ), EOK );
TEST( "exclude bla 2", char_map_exclude( & cm, "bla", 0 ), 2 );
TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL );
TEST( "find ucho 2", char_map_find( & cm, "ucho", 0 ), 2 );
TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 0, 3 ), EOK );
TEST( "find ucho 3", char_map_find( & cm, "ucho", 0 ), 3 );
TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 0, 5 ), EOK );
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
TEST( "add bla 6 eok", char_map_add( & cm, "bla", 0, 6 ), EOK );
TEST( "find bla 6", char_map_find( & cm, "bla", 0 ), 6 );
TEST( "exclude bla 6", char_map_exclude( & cm, "bla", 0 ), 6 );
TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL );
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
TEST( "add auto 7 eok", char_map_add( & cm, "auto", 0, 7 ), EOK );
TEST( "find auto 7", char_map_find( & cm, "auto", 0 ), 7 );
TEST( "add kara 8 eok", char_map_add( & cm, "kara", 0, 8 ), EOK );
TEST( "find kara 8", char_map_find( & cm, "kara", 0 ), 8 );
TEST( "add nic 9 eok", char_map_add( & cm, "nic", 0, 9 ), EOK );
TEST( "find nic 9", char_map_find( & cm, "nic", 0 ), 9 );
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
printf( "\n\tdestroy" );
char_map_destroy( & cm );
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL );
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL );
printf( "\nOK" );
 
#endif
250,31 → 250,31
 
icm.magic = 0;
printf( "\nGeneric char map test" );
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL );
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL );
TEST( "initialize", int_char_map_initialize( & icm ), EOK );
printf( "\n\texclude bla null" );
int_char_map_exclude( & icm, "bla" );
TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL );
TEST( "add bla x eok", int_char_map_add( & icm, "bla", x ), EOK );
TEST( "find bla x", int_char_map_find( & icm, "bla" ), x );
TEST( "add bla y eexists", int_char_map_add( & icm, "bla", y ), EEXISTS );
int_char_map_exclude( & icm, "bla", 0 );
TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL );
TEST( "add bla x eok", int_char_map_add( & icm, "bla", 0, x ), EOK );
TEST( "find bla x", int_char_map_find( & icm, "bla", 0 ), x );
TEST( "add bla y eexists", int_char_map_add( & icm, "bla", 0, y ), EEXISTS );
printf( "\n\texclude bla y" );
int_char_map_exclude( & icm, "bla" );
int_char_map_exclude( & icm, "bla", 0 );
printf( "\n\texclude bla null" );
int_char_map_exclude( & icm, "bla" );
TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", v ), EOK );
TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v );
TEST( "add bla w eok", int_char_map_add( & icm, "bla", w ), EOK );
TEST( "find bla w", int_char_map_find( & icm, "bla" ), w );
int_char_map_exclude( & icm, "bla", 0 );
TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", 0, v ), EOK );
TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v );
TEST( "add bla w eok", int_char_map_add( & icm, "bla", 0, w ), EOK );
TEST( "find bla w", int_char_map_find( & icm, "bla", 0 ), w );
printf( "\n\texclude bla" );
int_char_map_exclude( & icm, "bla" );
TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL );
TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v );
TEST( "add auto u eok", int_char_map_add( & icm, "auto", u ), EOK );
TEST( "find auto u", int_char_map_find( & icm, "auto" ), u );
int_char_map_exclude( & icm, "bla", 0 );
TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL );
TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v );
TEST( "add auto u eok", int_char_map_add( & icm, "auto", 0, u ), EOK );
TEST( "find auto u", int_char_map_find( & icm, "auto", 0 ), u );
printf( "\n\tdestroy" );
int_char_map_destroy( & icm );
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL );
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL );
printf( "\nOK" );
 
#endif
/branches/network/uspace/srv/net/Makefile
35,7 → 35,7
 
DIRS_MODULAR = ip \
tcp \
# arp \
arp \
# rarp \
# icmp \
# udp \
/branches/network/uspace/srv/net/err.h
27,20 → 27,37
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
* Common error processing codes and routines.
*/
 
#ifndef __NET_ERR_H__
#define __NET_ERR_H__
 
#include <errno.h>
 
#define ERROR_CODE error_check_return_value
#define ERROR_DECLARE int ERROR_CODE
/** An actual stored error code.
*/
#define ERROR_CODE error_check_return_value
 
/** An error processing routines declaration.
* This has to be declared in the block where the error processing is desired.
*/
#define ERROR_DECLARE int ERROR_CODE
 
/** Stores the value as an error code and checks if an error occured.
* @param value The value to be checked. May be a function call. Input parameter.
* @returns FALSE if the value indicates success (EOK).
* @returns TRUE otherwise.
*/
#define ERROR_OCCURED( value ) (( ERROR_CODE = ( value )) != EOK )
 
/** Checks if an error occured and immediatelly exits the actual function returning the error code.
* @param value The value to be checked. May be a function call. Input parameter.
*/
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURED( value )) return ERROR_CODE
 
#endif
/branches/network/uspace/srv/net/include/sockaddr.h
0,0 → 1,104
/*
* Copyright (c) 2008 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*
*/
 
#ifndef __NET_SOCKADDR_H__
#define __NET_SOCKADDR_H__
 
#include <sys/types.h>
 
#define INET_ADDRSTRLEN ( 4 * 3 + 3 )
#define INET6_ADDRSTRLEN ( 8 * 4 + 7 )
 
typedef struct sockaddr sockaddr_t;
typedef struct in_addr in_addr_t;
typedef struct sockaddr_in sockaddr_in_t;
typedef struct sockaddr_in6 sockaddr_in6_t;
typedef struct addrinfo addrinfo_t;
 
int inet_ntop( uint16_t family, const uint8_t * data, char * address, size_t length );
int inet_pton( uint16_t family, const char * address, uint8_t * data );
 
struct sockaddr{
uint16_t sa_family; // address family, AF_xxx
uint8_t sa_data[ 14 ]; // 14 bytes of protocol address
};
 
struct in_addr{
uint32_t s_addr; // that's a 32-bit int (4 bytes)
};
 
struct sockaddr_in{
uint16_t sin_family; // Address family, AF_INET
uint16_t sin_port; // Port number
struct in_addr sin_addr; // Internet address
uint8_t sin_zero[ 8 ]; // Same size as struct sockaddr
};
 
struct in6_addr{
unsigned char s6_addr[ 16 ]; // IPv6 address
};
 
struct sockaddr_in6{
uint16_t sin6_family; // address family, AF_INET6
uint16_t sin6_port; // port number, Network Byte Order
uint32_t sin6_flowinfo; // IPv6 flow information
struct in6_addr sin6_addr; // IPv6 address
uint32_t sin6_scope_id; // Scope ID
};
 
struct addrinfo{
int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc.
uint16_t ai_family; // AF_INET, AF_INET6, AF_UNSPEC
int ai_socktype; // SOCK_STREAM, SOCK_DGRAM
int ai_protocol; // use 0 for "any"
size_t ai_addrlen; // size of ai_addr in bytes
struct sockaddr * ai_addr; // struct sockaddr_in or _in6
char * ai_canonname; // full canonical hostname
struct addrinfo * ai_next; // linked list, next node
};
 
/*int getaddrinfo(const char *node, // e.g. "www.example.com" or IP
const char *service, // e.g. "http" or port number
const struct addrinfo *hints,
struct addrinfo **res);
 
getnameinfo
*/
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/include/hardware.h
===================================================================
--- network/uspace/srv/net/include/hardware.h (nonexistent)
+++ network/uspace/srv/net/include/hardware.h (revision 3846)
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2008 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
+ * Hardware types according to the online IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
+ * Names similar to the linux src/include/linux/if_arp.h header file.
+ */
+
+#ifndef __NET_HW_TYPES_H__
+#define __NET_HW_TYPES_H__
+
+/** Ethernet (10Mb) hardware type.
+ */
+#define HW_ETHER 1
+
+/** Experimental Ethernet (3Mb) hardware type.
+ */
+#define HW_EETHER 2
+
+/** Amateur Radio AX.25 hardware type.
+ */
+#define HW_AX25 3
+
+/** Proteon ProNET Token Ring hardware type.
+ */
+#define HW_PRONET 4
+
+/** Chaos hardware type.
+ */
+#define HW_CHAOS 5
+
+/** IEEE 802 Networks hardware type.
+ */
+#define HW_IEEE802 6
+
+/** ARCNET hardware type.
+ */
+#define HW_ARCNET 7
+
+/** Hyperchannel hardware type.
+ */
+#define HW_Hyperchannel 8
+
+/** Lanstar hardware type.
+ */
+#define HW_Lanstar 9
+
+/** Autonet Short Address hardware type.
+ */
+#define HW_ASA 10
+
+/** LocalTalk hardware type.
+ */
+#define HW_LocalTalk 11
+
+/** LocalNet (IBM PCNet or SYTEK LocalNET) hardware type.
+ */
+#define HW_LocalNet 12
+
+/** Ultra link hardware type.
+ */
+#define HW_Ultra_link 13
+
+/** SMDS hardware type.
+ */
+#define HW_SMDS 14
+
+/** Frame Relay DLCI hardware type.
+ */
+#define HW_DLCI 15
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM 16
+
+/** HDLC hardware type.
+ */
+#define HW_HDLC 17
+
+/** Fibre Channel hardware type.
+ */
+#define HW_Fibre_Channel 18
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM2 19
+
+/** Serial Line hardware type.
+ */
+#define HW_Serial_Line 20
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM3 21
+
+/** MIL-STD-188-220 hardware type.
+ */
+#define HW_MIL_STD_188_220 22
+
+/** Metricom hardware type.
+ */
+#define HW_METRICOM 23
+
+/** IEEE 1394.1995 hardware type.
+ */
+#define HW_IEEE1394 24
+
+/** MAPOS hardware type.
+ */
+#define HW_MAPOS 25
+
+/** Twinaxial hardware type.
+ */
+#define HW_Twinaxial 26
+
+/** EUI-64 hardware type.
+ */
+#define HW_EUI64 27
+
+/** HIPARP hardware type.
+ */
+#define HW_HIPARP 28
+
+/** IP and ARP over ISO 7816-3 hardware type.
+ */
+#define HW_ISO_7816_3 29
+
+/** ARPSec hardware type.
+ */
+#define HW_ARPSec 30
+
+/** IPsec tunnel hardware type.
+ */
+#define HW_IPsec_tunnel 31
+
+/** InfiniBand (TM) hardware type.
+ */
+#define HW_INFINIBAND 32
+
+/** TIA-102 Project 25 Common Air Interface (CAI) hardware type.
+ */
+#define HW_CAI 33
+
+/** Wiegand Interface hardware type.
+ */
+#define HW_Wiegand 34
+
+/** Pure IP hardware type.
+ */
+#define HW_Pure_IP 35
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/hardware.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/include/protocol_map.h
===================================================================
--- network/uspace/srv/net/include/protocol_map.h (nonexistent)
+++ network/uspace/srv/net/include/protocol_map.h (revision 3846)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2008 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup net
+ * @{
+ */
+
+/** @file
+ *
+ */
+
+#ifndef __NET_PROTOCOL_MAP_H__
+#define __NET_PROTOCOL_MAP_H__
+
+#include <ipc/services.h>
+
+#include "ethernet_protocols.h"
+
+static inline int protocol_map( services_t nil, services_t il ){
+ switch( nil ){
+ case SERVICE_ETHERNET:
+ switch( il ){
+ case SERVICE_IP:
+ return ETH_P_IP;
+ case SERVICE_ARP:
+ return ETH_P_ARP;
+ default:
+ return 0;
+ }
+ default:
+ return 0;
+ }
+}
+
+static inline services_t protocol_unmap( services_t nil, int protocol ){
+ switch( nil ){
+ case SERVICE_ETHERNET:
+ switch( protocol ){
+ case ETH_P_IP:
+ return SERVICE_IP;
+ case ETH_P_ARP:
+ return SERVICE_ARP;
+ default:
+ return 0;
+ }
+ default:
+ return 0;
+ }
+}
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/protocol_map.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/include/byteorder.h
===================================================================
--- network/uspace/srv/net/include/byteorder.h (nonexistent)
+++ network/uspace/srv/net/include/byteorder.h (revision 3846)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2008 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
+ * Host - network byte order manipulation functions.
+ */
+
+#ifndef __NET_BYTEORDER_H__
+#define __NET_BYTEORDER_H__
+
+#include <byteorder.h>
+
+#ifdef ARCH_IS_BIG_ENDIAN
+
+// Already in the network byte order.
+
+ /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
+ * @param number The number in the host byte order to be converted.
+ * @returns The number in the network byte order.
+ */
+ #define htons( number ) ( number )
+
+ /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
+ * @param number The number in the host byte order to be converted.
+ * @returns The number in the network byte order.
+ */
+ #define htonl( number ) ( number )
+
+ /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
+ * @param number The number in the network byte order to be converted.
+ * @returns The number in the host byte order.
+ */
+ #define ntohs( number ) ( number )
+
+ /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
+ * @param number The number in the network byte order to be converted.
+ * @returns The number in the host byte order.
+ */
+ #define ntohl( number ) ( number )
+
+#else
+
+// Has to be swapped.
+
+ /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
+ * @param number The number in the host byte order to be converted.
+ * @returns The number in the network byte order.
+ */
+ #define htons( number ) uint16_t_byteorder_swap( number )
+
+ /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
+ * @param number The number in the host byte order to be converted.
+ * @returns The number in the network byte order.
+ */
+ #define htonl( number ) uint32_t_byteorder_swap( number )
+
+ /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
+ * @param number The number in the network byte order to be converted.
+ * @returns The number in the host byte order.
+ */
+ #define ntohs( number ) uint16_t_byteorder_swap( number )
+
+ /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
+ * @param number The number in the network byte order to be converted.
+ * @returns The number in the host byte order.
+ */
+ #define ntohl( number ) uint32_t_byteorder_swap( number )
+
+#endif
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/byteorder.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/include/ethernet_protocols.h
===================================================================
--- network/uspace/srv/net/include/ethernet_protocols.h (nonexistent)
+++ network/uspace/srv/net/include/ethernet_protocols.h (revision 3846)
@@ -0,0 +1,996 @@
+/*
+ * Copyright (c) 2008 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
+ * Ethernet protocol numbers according to the online IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009.
+ * Names according to the linux src/include/linux/if_ether.h header file.
+ */
+
+#ifndef __NET_ETHERNET_PROTOCOLS_H__
+#define __NET_ETHERNET_PROTOCOLS_H__
+
+/** Ethernet loopback packet protocol type.
+ */
+#define ETH_P_LOOP 0x0060
+
+/** XEROX PUP (see 0A00) ethernet protocol type.
+ */
+#define ETH_P_PUP 0x0200
+
+/** PUP Addr Trans (see 0A01) ethernet protocol type.
+ */
+#define ETH_P_PUPAT 0x0201
+
+/** Nixdorf ethernet protocol type.
+ */
+#define ETH_P_Nixdorf 0x0400
+
+/** XEROX NS IDP ethernet protocol type.
+ */
+#define ETH_P_XEROX_NS_IDP 0x0600
+
+/** DLOG ethernet protocol type.
+ */
+#define ETH_P_DLOG 0x0660
+
+/** DLOG ethernet protocol type.
+ */
+#define ETH_P_DLOG2 0x0661
+
+/** Internet IP (IPv4) ethernet protocol type.
+ */
+#define ETH_P_IP 0x0800
+
+/** X.75 Internet ethernet protocol type.
+ */
+#define ETH_P_X_75 0x0801
+
+/** NBS Internet ethernet protocol type.
+ */
+#define ETH_P_NBS 0x0802
+
+/** ECMA Internet ethernet protocol type.
+ */
+#define ETH_P_ECMA 0x0803
+
+/** Chaosnet ethernet protocol type.
+ */
+#define ETH_P_Chaosnet 0x0804
+
+/** X.25 Level 3 ethernet protocol type.
+ */
+#define ETH_P_X25 0x0805
+
+/** ARP ethernet protocol type.
+ */
+#define ETH_P_ARP 0x0806
+
+/** XNS Compatability ethernet protocol type.
+ */
+#define ETH_P_XNS_Compatability 0x0807
+
+/** Frame Relay ARP ethernet protocol type.
+ */
+#define ETH_P_Frame_Relay_ARP 0x0808
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private 0x081C
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MIN 0x0888
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MAX 0x088A
+
+/** Ungermann-Bass net debugr ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_net_debugr 0x0900
+
+/** Xerox IEEE802.3 PUP ethernet protocol type.
+ */
+#define ETH_P_IEEEPUP 0x0A00
+
+/** PUP Addr Trans ethernet protocol type.
+ */
+#define ETH_P_IEEEPUPAT 0x0A01
+
+/** Banyan VINES ethernet protocol type.
+ */
+#define ETH_P_Banyan_VINES 0x0BAD
+
+/** VINES Loopback ethernet protocol type.
+ */
+#define ETH_P_VINES_Loopback 0x0BAE
+
+/** VINES Echo ethernet protocol type.
+ */
+#define ETH_P_VINES_Echo 0x0BAF
+
+/** Berkeley Trailer nego ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_nego 0x1000
+
+/** Berkeley Trailer encap/IP ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_encapIP_MIN 0x1001
+
+/** Berkeley Trailer encap/IP ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_encapIP_MAX 0x100F
+
+/** Valid Systems ethernet protocol type.
+ */
+#define ETH_P_Valid_Systems 0x1600
+
+/** PCS Basic Block Protocol ethernet protocol type.
+ */
+#define ETH_P_PCS_Basic_Block_Protocol 0x4242
+
+/** BBN Simnet ethernet protocol type.
+ */
+#define ETH_P_BBN_Simnet 0x5208
+
+/** DEC Unassigned (Exp.) ethernet protocol type.
+ */
+#define ETH_P_DEC 0x6000
+
+/** DEC MOP Dump/Load ethernet protocol type.
+ */
+#define ETH_P_DNA_DL 0x6001
+
+/** DEC MOP Remote Console ethernet protocol type.
+ */
+#define ETH_P_DNA_RC 0x6002
+
+/** DEC DECNET Phase IV Route ethernet protocol type.
+ */
+#define ETH_P_DNA_RT 0x6003
+
+/** DEC LAT ethernet protocol type.
+ */
+#define ETH_P_LAT 0x6004
+
+/** DEC Diagnostic Protocol ethernet protocol type.
+ */
+#define ETH_P_DIAG 0x6005
+
+/** DEC Customer Protocol ethernet protocol type.
+ */
+#define ETH_P_CUST 0x6006
+
+/** DEC LAVC, SCA ethernet protocol type.
+ */
+#define ETH_P_SCA 0x6007
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN 0x6008
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX 0x6009
+
+/** Com Corporation ethernet protocol type.
+ */
+#define ETH_P_Com_Corporation_MIN 0x6010
+
+/** Com Corporation ethernet protocol type.
+ */
+#define ETH_P_Com_Corporation_MAX 0x6014
+
+/** Trans Ether Bridging ethernet protocol type.
+ */
+#define ETH_P_Trans_Ether_Bridging 0x6558
+
+/** Raw Frame Relay ethernet protocol type.
+ */
+#define ETH_P_Raw_Frame_Relay 0x6559
+
+/** Ungermann-Bass download ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_download 0x7000
+
+/** Ungermann-Bass dia/loop ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_dialoop 0x7002
+
+/** LRT ethernet protocol type.
+ */
+#define ETH_P_LRT_MIN 0x7020
+
+/** LRT ethernet protocol type.
+ */
+#define ETH_P_LRT_MAX 0x7029
+
+/** Proteon ethernet protocol type.
+ */
+#define ETH_P_Proteon 0x7030
+
+/** Cabletron ethernet protocol type.
+ */
+#define ETH_P_Cabletron 0x7034
+
+/** Cronus VLN ethernet protocol type.
+ */
+#define ETH_P_Cronus_VLN 0x8003
+
+/** Cronus Direct ethernet protocol type.
+ */
+#define ETH_P_Cronus_Direct 0x8004
+
+/** HP Probe ethernet protocol type.
+ */
+#define ETH_P_HP_Probe 0x8005
+
+/** Nestar ethernet protocol type.
+ */
+#define ETH_P_Nestar 0x8006
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T 0x8008
+
+/** Excelan ethernet protocol type.
+ */
+#define ETH_P_Excelan 0x8010
+
+/** SGI diagnostics ethernet protocol type.
+ */
+#define ETH_P_SGI_diagnostics 0x8013
+
+/** SGI network games ethernet protocol type.
+ */
+#define ETH_P_SGI_network_games 0x8014
+
+/** SGI reserved ethernet protocol type.
+ */
+#define ETH_P_SGI_reserved 0x8015
+
+/** SGI bounce server ethernet protocol type.
+ */
+#define ETH_P_SGI_bounce_server 0x8016
+
+/** Apollo Domain ethernet protocol type.
+ */
+#define ETH_P_Apollo_Domain 0x8019
+
+/** Tymshare ethernet protocol type.
+ */
+#define ETH_P_Tymshare 0x802E
+
+/** Tigan, Inc. ethernet protocol type.
+ */
+#define ETH_P_Tigan 0x802F
+
+/** Reverse ARP ethernet protocol type.
+ */
+#define ETH_P_RARP 0x8035
+
+/** Aeonic Systems ethernet protocol type.
+ */
+#define ETH_P_Aeonic_Systems 0x8036
+
+/** DEC LANBridge ethernet protocol type.
+ */
+#define ETH_P_DEC_LANBridge 0x8038
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN1 0x8039
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX2 0x803C
+
+/** DEC Ethernet Encryption ethernet protocol type.
+ */
+#define ETH_P_DEC_Ethernet_Encryption 0x803D
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned 0x803E
+
+/** DEC LAN Traffic Monitor ethernet protocol type.
+ */
+#define ETH_P_DEC_LAN_Traffic_Monitor 0x803F
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN3 0x8040
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX3 0x8042
+
+/** Planning Research Corp. ethernet protocol type.
+ */
+#define ETH_P_Planning_Research_Corp 0x8044
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T2 0x8046
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T3 0x8047
+
+/** ExperData ethernet protocol type.
+ */
+#define ETH_P_ExperData 0x8049
+
+/** Stanford V Kernel exp. ethernet protocol type.
+ */
+#define ETH_P_Stanford_V_Kernel_exp 0x805B
+
+/** Stanford V Kernel prod. ethernet protocol type.
+ */
+#define ETH_P_Stanford_V_Kernel_prod 0x805C
+
+/** Evans & Sutherland ethernet protocol type.
+ */
+#define ETH_P_Evans_Sutherland 0x805D
+
+/** Little Machines ethernet protocol type.
+ */
+#define ETH_P_Little_Machines 0x8060
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers 0x8062
+
+/** Univ. of Mass. @ Amherst ethernet protocol type.
+ */
+#define ETH_P_Univ_of_Mass 0x8065
+
+/** Univ. of Mass. @ Amherst ethernet protocol type.
+ */
+#define ETH_P_Univ_of_Mass2 0x8066
+
+/** Veeco Integrated Auto. ethernet protocol type.
+ */
+#define ETH_P_Veeco_Integrated_Auto 0x8067
+
+/** General Dynamics ethernet protocol type.
+ */
+#define ETH_P_General_Dynamics 0x8068
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T4 0x8069
+
+/** Autophon ethernet protocol type.
+ */
+#define ETH_P_Autophon 0x806A
+
+/** ComDesign ethernet protocol type.
+ */
+#define ETH_P_ComDesign 0x806C
+
+/** Computgraphic Corp. ethernet protocol type.
+ */
+#define ETH_P_Computgraphic_Corp 0x806D
+
+/** Landmark Graphics Corp. ethernet protocol type.
+ */
+#define ETH_P_Landmark_Graphics_Corp_MIN 0x806E
+
+/** Landmark Graphics Corp. ethernet protocol type.
+ */
+#define ETH_P_Landmark_Graphics_Corp_MAX 0x8077
+
+/** Matra ethernet protocol type.
+ */
+#define ETH_P_Matra 0x807A
+
+/** Dansk Data Elektronik ethernet protocol type.
+ */
+#define ETH_P_Dansk_Data_Elektronik 0x807B
+
+/** Merit Internodal ethernet protocol type.
+ */
+#define ETH_P_Merit_Internodal 0x807C
+
+/** Vitalink Communications ethernet protocol type.
+ */
+#define ETH_P_Vitalink_Communications_MIN 0x807D
+
+/** Vitalink Communications ethernet protocol type.
+ */
+#define ETH_P_Vitalink_Communications_MAX 0x807F
+
+/** Vitalink TransLAN III ethernet protocol type.
+ */
+#define ETH_P_Vitalink_TransLAN_III 0x8080
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers_MIN 0x8081
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers_MAX 0x8083
+
+/** Appletalk ethernet protocol type.
+ */
+#define ETH_P_ATALK 0x809B
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MIN 0x809C
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MAX 0x809E
+
+/** Spider Systems Ltd. ethernet protocol type.
+ */
+#define ETH_P_Spider_Systems_Ltd 0x809F
+
+/** Nixdorf Computers ethernet protocol type.
+ */
+#define ETH_P_Nixdorf_Computers 0x80A3
+
+/** Siemens Gammasonics Inc. ethernet protocol type.
+ */
+#define ETH_P_Siemens_Gammasonics_Inc_MIN 0x80A4
+
+/** Siemens Gammasonics Inc. ethernet protocol type.
+ */
+#define ETH_P_Siemens_Gammasonics_Inc_MAX 0x80B3
+
+/** DCA Data Exchange Cluster ethernet protocol type.
+ */
+#define ETH_P_DCA_Data_Exchange_Cluster_MIN 0x80C0
+
+/** DCA Data Exchange Cluster ethernet protocol type.
+ */
+#define ETH_P_DCA_Data_Exchange_Cluster_MAX 0x80C3
+
+/** Banyan Systems ethernet protocol type.
+ */
+#define ETH_P_Banyan_Systems 0x80C4
+
+/** Banyan Systems ethernet protocol type.
+ */
+#define ETH_P_Banyan_Systems2 0x80C5
+
+/** Pacer Software ethernet protocol type.
+ */
+#define ETH_P_Pacer_Software 0x80C6
+
+/** Applitek Corporation ethernet protocol type.
+ */
+#define ETH_P_Applitek_Corporation 0x80C7
+
+/** Intergraph Corporation ethernet protocol type.
+ */
+#define ETH_P_Intergraph_Corporation_MIN 0x80C8
+
+/** Intergraph Corporation ethernet protocol type.
+ */
+#define ETH_P_Intergraph_Corporation_MAX 0x80CC
+
+/** Harris Corporation ethernet protocol type.
+ */
+#define ETH_P_Harris_Corporation_MIN 0x80CD
+
+/** Harris Corporation ethernet protocol type.
+ */
+#define ETH_P_Harris_Corporation_MAX 0x80CE
+
+/** Taylor Instrument ethernet protocol type.
+ */
+#define ETH_P_Taylor_Instrument_MIN 0x80CF
+
+/** Taylor Instrument ethernet protocol type.
+ */
+#define ETH_P_Taylor_Instrument_MAX 0x80D2
+
+/** Rosemount Corporation ethernet protocol type.
+ */
+#define ETH_P_Rosemount_Corporation_MIN 0x80D3
+
+/** Rosemount Corporation ethernet protocol type.
+ */
+#define ETH_P_Rosemount_Corporation_MAX 0x80D4
+
+/** IBM SNA Service on Ether ethernet protocol type.
+ */
+#define ETH_P_IBM_SNA_Service_on_Ether 0x80D5
+
+/** Varian Associates ethernet protocol type.
+ */
+#define ETH_P_Varian_Associates 0x80DD
+
+/** Integrated Solutions TRFS ethernet protocol type.
+ */
+#define ETH_P_Integrated_Solutions_TRFS_MIN 0x80DE
+
+/** Integrated Solutions TRFS ethernet protocol type.
+ */
+#define ETH_P_Integrated_Solutions_TRFS_MAX 0x80DF
+
+/** Allen-Bradley ethernet protocol type.
+ */
+#define ETH_P_Allen_Bradley_MIN 0x80E0
+
+/** Allen-Bradley ethernet protocol type.
+ */
+#define ETH_P_Allen_Bradley_MAX 0x80E3
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MIN2 0x80E4
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MAX2 0x80F0
+
+/** Retix ethernet protocol type.
+ */
+#define ETH_P_Retix 0x80F2
+
+/** AppleTalk AARP (Kinetics) ethernet protocol type.
+ */
+#define ETH_P_AARP 0x80F3
+
+/** Kinetics ethernet protocol type.
+ */
+#define ETH_P_Kinetics_MIN 0x80F4
+
+/** Kinetics ethernet protocol type.
+ */
+#define ETH_P_Kinetics_MAX 0x80F5
+
+/** Apollo Computer ethernet protocol type.
+ */
+#define ETH_P_Apollo_Computer 0x80F7
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications 0x80FF
+
+/** IEEE 802.1Q VLAN-tagged frames (initially Wellfleet) ethernet protocol type.
+ */
+#define ETH_P_8021Q 0x8100
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications_MIN 0x8101
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications_MAX 0x8103
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private_MIN 0x8107
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private_MAX 0x8109
+
+/** Hayes Microcomputers ethernet protocol type.
+ */
+#define ETH_P_Hayes_Microcomputers 0x8130
+
+/** VG Laboratory Systems ethernet protocol type.
+ */
+#define ETH_P_VG_Laboratory_Systems 0x8131
+
+/** Bridge Communications ethernet protocol type.
+ */
+#define ETH_P_Bridge_Communications_MIN 0x8132
+
+/** Bridge Communications ethernet protocol type.
+ */
+#define ETH_P_Bridge_Communications_MAX 0x8136
+
+/** Novell, Inc. ethernet protocol type.
+ */
+#define ETH_P_Novell_Inc_MIN 0x8137
+
+/** Novell, Inc. ethernet protocol type.
+ */
+#define ETH_P_Novell_Inc_MAX 0x8138
+
+/** KTI ethernet protocol type.
+ */
+#define ETH_P_KTI_MIN 0x8139
+
+/** KTI ethernet protocol type.
+ */
+#define ETH_P_KTI_MAX 0x813D
+
+/** Logicraft ethernet protocol type.
+ */
+#define ETH_P_Logicraft 0x8148
+
+/** Network Computing Devices ethernet protocol type.
+ */
+#define ETH_P_Network_Computing_Devices 0x8149
+
+/** Alpha Micro ethernet protocol type.
+ */
+#define ETH_P_Alpha_Micro 0x814A
+
+/** SNMP ethernet protocol type.
+ */
+#define ETH_P_SNMP 0x814C
+
+/** BIIN ethernet protocol type.
+ */
+#define ETH_P_BIIN 0x814D
+
+/** BIIN ethernet protocol type.
+ */
+#define ETH_P_BIIN2 0x814E
+
+/** Technically Elite Concept ethernet protocol type.
+ */
+#define ETH_P_Technically_Elite_Concept 0x814F
+
+/** Rational Corp ethernet protocol type.
+ */
+#define ETH_P_Rational_Corp 0x8150
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MIN 0x8151
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MAX 0x8153
+
+/** Computer Protocol Pty Ltd ethernet protocol type.
+ */
+#define ETH_P_Computer_Protocol_Pty_Ltd_MIN 0x815C
+
+/** Computer Protocol Pty Ltd ethernet protocol type.
+ */
+#define ETH_P_Computer_Protocol_Pty_Ltd_MAX 0x815E
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MIN 0x8164
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MAX 0x8166
+
+/** XTP ethernet protocol type.
+ */
+#define ETH_P_XTP 0x817D
+
+/** SGI/Time Warner prop. ethernet protocol type.
+ */
+#define ETH_P_SGITime_Warner_prop 0x817E
+
+/** HIPPI-FP encapsulation ethernet protocol type.
+ */
+#define ETH_P_HIPPI_FP_encapsulation 0x8180
+
+/** STP, HIPPI-ST ethernet protocol type.
+ */
+#define ETH_P_STP_HIPPI_ST 0x8181
+
+/** Reserved for HIPPI-6400 ethernet protocol type.
+ */
+#define ETH_P_Reserved_for_HIPPI_6400 0x8182
+
+/** Reserved for HIPPI-6400 ethernet protocol type.
+ */
+#define ETH_P_Reserved_for_HIPPI_64002 0x8183
+
+/** Silicon Graphics prop. ethernet protocol type.
+ */
+#define ETH_P_Silicon_Graphics_prop_MIN 0x8184
+
+/** Silicon Graphics prop. ethernet protocol type.
+ */
+#define ETH_P_Silicon_Graphics_prop_MAX 0x818C
+
+/** Motorola Computer ethernet protocol type.
+ */
+#define ETH_P_Motorola_Computer 0x818D
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MIN2 0x819A
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MAX2 0x81A3
+
+/** ARAI Bunkichi ethernet protocol type.
+ */
+#define ETH_P_ARAI_Bunkichi 0x81A4
+
+/** RAD Network Devices ethernet protocol type.
+ */
+#define ETH_P_RAD_Network_Devices_MIN 0x81A5
+
+/** RAD Network Devices ethernet protocol type.
+ */
+#define ETH_P_RAD_Network_Devices_MAX 0x81AE
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MIN2 0x81B7
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MAX2 0x81B9
+
+/** Apricot Computers ethernet protocol type.
+ */
+#define ETH_P_Apricot_Computers_MIN 0x81CC
+
+/** Apricot Computers ethernet protocol type.
+ */
+#define ETH_P_Apricot_Computers_MAX 0x81D5
+
+/** Artisoft ethernet protocol type.
+ */
+#define ETH_P_Artisoft_MIN 0x81D6
+
+/** Artisoft ethernet protocol type.
+ */
+#define ETH_P_Artisoft_MAX 0x81DD
+
+/** Polygon ethernet protocol type.
+ */
+#define ETH_P_Polygon_MIN 0x81E6
+
+/** Polygon ethernet protocol type.
+ */
+#define ETH_P_Polygon_MAX 0x81EF
+
+/** Comsat Labs ethernet protocol type.
+ */
+#define ETH_P_Comsat_Labs_MIN 0x81F0
+
+/** Comsat Labs ethernet protocol type.
+ */
+#define ETH_P_Comsat_Labs_MAX 0x81F2
+
+/** SAIC ethernet protocol type.
+ */
+#define ETH_P_SAIC_MIN 0x81F3
+
+/** SAIC ethernet protocol type.
+ */
+#define ETH_P_SAIC_MAX 0x81F5
+
+/** VG Analytical ethernet protocol type.
+ */
+#define ETH_P_VG_Analytical_MIN 0x81F6
+
+/** VG Analytical ethernet protocol type.
+ */
+#define ETH_P_VG_Analytical_MAX 0x81F8
+
+/** Quantum Software ethernet protocol type.
+ */
+#define ETH_P_Quantum_Software_MIN 0x8203
+
+/** Quantum Software ethernet protocol type.
+ */
+#define ETH_P_Quantum_Software_MAX 0x8205
+
+/** Ascom Banking Systems ethernet protocol type.
+ */
+#define ETH_P_Ascom_Banking_Systems_MIN 0x8221
+
+/** Ascom Banking Systems ethernet protocol type.
+ */
+#define ETH_P_Ascom_Banking_Systems_MAX 0x8222
+
+/** Advanced Encryption Syste ethernet protocol type.
+ */
+#define ETH_P_Advanced_Encryption_Syste_MIN 0x823E
+
+/** Advanced Encryption Syste ethernet protocol type.
+ */
+#define ETH_P_Advanced_Encryption_Syste_MAX 0x8240
+
+/** Athena Programming ethernet protocol type.
+ */
+#define ETH_P_Athena_Programming_MIN 0x827F
+
+/** Athena Programming ethernet protocol type.
+ */
+#define ETH_P_Athena_Programming_MAX 0x8282
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MIN2 0x8263
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MAX2 0x826A
+
+/** Inst Ind Info Tech ethernet protocol type.
+ */
+#define ETH_P_Inst_Ind_Info_Tech_MIN 0x829A
+
+/** Inst Ind Info Tech ethernet protocol type.
+ */
+#define ETH_P_Inst_Ind_Info_Tech_MAX 0x829B
+
+/** Taurus Controls ethernet protocol type.
+ */
+#define ETH_P_Taurus_Controls_MIN 0x829C
+
+/** Taurus Controls ethernet protocol type.
+ */
+#define ETH_P_Taurus_Controls_MAX 0x82AB
+
+/** Walker Richer & Quinn ethernet protocol type.
+ */
+#define ETH_P_Walker_Richer_Quinn_MIN 0x82AC
+
+/** Walker Richer & Quinn ethernet protocol type.
+ */
+#define ETH_P_Walker_Richer_Quinn_MAX 0x8693
+
+/** Idea Courier ethernet protocol type.
+ */
+#define ETH_P_Idea_Courier_MIN 0x8694
+
+/** Idea Courier ethernet protocol type.
+ */
+#define ETH_P_Idea_Courier_MAX 0x869D
+
+/** Computer Network Tech ethernet protocol type.
+ */
+#define ETH_P_Computer_Network_Tech_MIN 0x869E
+
+/** Computer Network Tech ethernet protocol type.
+ */
+#define ETH_P_Computer_Network_Tech_MAX 0x86A1
+
+/** Gateway Communications ethernet protocol type.
+ */
+#define ETH_P_Gateway_Communications_MIN 0x86A3
+
+/** Gateway Communications ethernet protocol type.
+ */
+#define ETH_P_Gateway_Communications_MAX 0x86AC
+
+/** SECTRA ethernet protocol type.
+ */
+#define ETH_P_SECTRA 0x86DB
+
+/** Delta Controls ethernet protocol type.
+ */
+#define ETH_P_Delta_Controls 0x86DE
+
+/** IPv6 ethernet protocol type.
+ */
+#define ETH_P_IPV6 0x86DD
+
+/** ATOMIC ethernet protocol type.
+ */
+#define ETH_P_ATOMIC 0x86DF
+
+/** Landis & Gyr Powers ethernet protocol type.
+ */
+#define ETH_P_Landis_Gyr_Powers_MIN 0x86E0
+
+/** Landis & Gyr Powers ethernet protocol type.
+ */
+#define ETH_P_Landis_Gyr_Powers_MAX 0x86EF
+
+/** Motorola ethernet protocol type.
+ */
+#define ETH_P_Motorola_MIN 0x8700
+
+/** Motorola ethernet protocol type.
+ */
+#define ETH_P_Motorola_MAX 0x8710
+
+/** TCP/IP Compression ethernet protocol type.
+ */
+#define ETH_P_TCPIP_Compression 0x876B
+
+/** IP Autonomous Systems ethernet protocol type.
+ */
+#define ETH_P_IP_Autonomous_Systems 0x876C
+
+/** Secure Data ethernet protocol type.
+ */
+#define ETH_P_Secure_Data 0x876D
+
+/** PPP ethernet protocol type.
+ */
+#define ETH_P_PPP 0x880B
+
+/** MPLS ethernet protocol type.
+ */
+#define ETH_P_MPLS_UC 0x8847
+
+/** MPLS with upstream-assigned label ethernet protocol type.
+ */
+#define ETH_P_MPLS_MC 0x8848
+
+/** Invisible Software ethernet protocol type.
+ */
+#define ETH_P_Invisible_Software_MIN 0x8A96
+
+/** Invisible Software ethernet protocol type.
+ */
+#define ETH_P_Invisible_Software_MAX 0x8A97
+
+/** PPPoE Discovery Stage ethernet protocol type.
+ */
+#define ETH_P_PPP_DISC 0x8863
+
+/** PPPoE Session Stage ethernet protocol type.
+ */
+#define ETH_P_PPP_SES 0x8864
+
+/** Loopback ethernet protocol type.
+ */
+#define ETH_P_Loopback 0x9000
+
+/** Com(Bridge) XNS Sys Mgmt ethernet protocol type.
+ */
+#define ETH_P_Com_XNS_Sys_Mgmt 0x9001
+
+/** Com(Bridge) TCP-IP Sys ethernet protocol type.
+ */
+#define ETH_P_Com_TCP_IP_Sys 0x9002
+
+/** Com(Bridge) loop detect ethernet protocol type.
+ */
+#define ETH_P_Com_loop_detect 0x9003
+
+/** BBN VITAL-LanBridge cache ethernet protocol type.
+ */
+#define ETH_P_BBN_VITAL_LanBridge_cache 0xFF00
+
+/** ISC Bunker Ramo ethernet protocol type.
+ */
+#define ETH_P_ISC_Bunker_Ramo_MIN 0xFF00
+
+/** ISC Bunker Ramo ethernet protocol type.
+ */
+#define ETH_P_ISC_Bunker_Ramo_MAX 0xFF0F
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/ethernet_protocols.h
Property changes:
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: network/uspace/srv/net/include/protocols.h
===================================================================
--- network/uspace/srv/net/include/protocols.h (nonexistent)
+++ network/uspace/srv/net/include/protocols.h (revision 3846)
@@ -0,0 +1,614 @@
+/*
+ * Copyright (c) 2008 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 online 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 interenet protocol number.
+ */
+#define IPPROTO_HOPOPT 0
+
+/** Internet Control Message interenet protocol number.
+ */
+#define IPPROTO_ICMP 1
+
+/** Internet Group Management interenet protocol number.
+ */
+#define IPPROTO_IGMP 2
+
+/** Gateway-to-Gateway interenet protocol number.
+ */
+#define IPPROTO_GGP 3
+
+/** IP in IP (encapsulation) interenet protocol number.
+ */
+#define IPPROTO_IP 4
+
+/** Stream interenet protocol number.
+ */
+#define IPPROTO_ST 5
+
+/** Transmission Control interenet protocol number.
+ */
+#define IPPROTO_TCP 6
+
+/** CBT interenet protocol number.
+ */
+#define IPPROTO_CBT 7
+
+/** Exterior Gateway Protocol interenet protocol number.
+ */
+#define IPPROTO_EGP 8
+
+/** any private interior gateway
+(used by Cisco for their IGRP) interenet protocol number.
+ */
+#define IPPROTO_IGP 9
+
+/** BBN RCC Monitoring interenet protocol number.
+ */
+#define IPPROTO_BBN_RCC_MON 10
+
+/** Network Voice Protocol interenet protocol number.
+ */
+#define IPPROTO_NVP_II 11
+
+/** PUP interenet protocol number.
+ */
+#define IPPROTO_PUP 12
+
+/** ARGUS interenet protocol number.
+ */
+#define IPPROTO_ARGUS 13
+
+/** EMCON interenet protocol number.
+ */
+#define IPPROTO_EMCON 14
+
+/** Cross Net Debugger interenet protocol number.
+ */
+#define IPPROTO_XNET 15
+
+/** Chaos interenet protocol number.
+ */
+#define IPPROTO_CHAOS 16
+
+/** User Datagram interenet protocol number.
+ */
+#define IPPROTO_UDP 17
+
+/** Multiplexing interenet protocol number.
+ */
+#define IPPROTO_MUX 18
+
+/** DCN Measurement Subsystems interenet protocol number.
+ */
+#define IPPROTO_DCN_MEAS 19
+
+/** Host Monitoring interenet protocol number.
+ */
+#define IPPROTO_HMP 20
+
+/** Packet Radio Measurement interenet protocol number.
+ */
+#define IPPROTO_PRM 21
+
+/** XEROX NS IDP interenet protocol number.
+ */
+#define IPPROTO_XNS_IDP 22
+
+/** Trunk-1 interenet protocol number.
+ */
+#define IPPROTO_TRUNK_1 23
+
+/** Trunk-2 interenet protocol number.
+ */
+#define IPPROTO_TRUNK_2 24
+
+/** Leaf-1 interenet protocol number.
+ */
+#define IPPROTO_LEAF_1 25
+
+/** Leaf-2 interenet protocol number.
+ */
+#define IPPROTO_LEAF_2 26
+
+/** Reliable Data Protocol interenet protocol number.
+ */
+#define IPPROTO_RDP 27
+
+/** Internet Reliable Transaction interenet protocol number.
+ */
+#define IPPROTO_IRTP 28
+
+/** ISO Transport Protocol Class 4 interenet protocol number.
+ */
+#define IPPROTO_ISO_TP4 29
+
+/** Bulk Data Transfer Protocol interenet protocol number.
+ */
+#define IPPROTO_NETBLT 30
+
+/** MFE Network Services Protocol interenet protocol number.
+ */
+#define IPPROTO_MFE_NSP 31
+
+/** MERIT Internodal Protocol interenet protocol number.
+ */
+#define IPPROTO_MERIT_INP 32
+
+/** Datagram Congestion Control Protocol interenet protocol number.
+ */
+#define IPPROTO_DCCP 33
+
+/** Third Party Connect Protocol interenet protocol number.
+ */
+#define IPPROTO_3PC 34
+
+/** Inter-Domain Policy Routing Protocol interenet protocol number.
+ */
+#define IPPROTO_IDPR 35
+
+/** XTP interenet protocol number.
+ */
+#define IPPROTO_XTP 36
+
+/** Datagram Delivery Protocol interenet protocol number.
+ */
+#define IPPROTO_DDP 37
+
+/** IDPR Control Message Transport Proto interenet protocol number.
+ */
+#define IPPROTO_IDPR_CMTP 38
+
+/** TP++ Transport Protocol interenet protocol number.
+ */
+#define IPPROTO_TP 39
+
+/** IL Transport Protocol interenet protocol number.
+ */
+#define IPPROTO_IL 40
+
+/** Ipv6 interenet protocol number.
+ */
+#define IPPROTO_IPV6 41
+
+/** Source Demand Routing Protocol interenet protocol number.
+ */
+#define IPPROTO_SDRP 42
+
+/** Routing Header for IPv6 interenet protocol number.
+ */
+#define IPPROTO_IPv6_Route 43
+
+/** Fragment Header for IPv6 interenet protocol number.
+ */
+#define IPPROTO_IPv6_Frag 44
+
+/** Inter-Domain Routing Protocol interenet protocol number.
+ */
+#define IPPROTO_IDRP 45
+
+/** Reservation Protocol interenet protocol number.
+ */
+#define IPPROTO_RSVP 46
+
+/** General Routing Encapsulation interenet protocol number.
+ */
+#define IPPROTO_GRE 47
+
+/** Dynamic Source Routing Protocol interenet protocol number.
+ */
+#define IPPROTO_DSR 48
+
+/** BNA interenet protocol number.
+ */
+#define IPPROTO_BNA 49
+
+/** Encap Security Payload interenet protocol number.
+ */
+#define IPPROTO_ESP 50
+
+/** Authentication Header interenet protocol number.
+ */
+#define IPPROTO_AH 51
+
+/** Integrated Net Layer Security TUBA interenet protocol number.
+ */
+#define IPPROTO_I_NLSP 52
+
+/** IP with Encryption interenet protocol number.
+ */
+#define IPPROTO_SWIPE 53
+
+/** NBMA Address Resolution Protocol interenet protocol number.
+ */
+#define IPPROTO_NARP 54
+
+/** IP Mobility interenet protocol number.
+ */
+#define IPPROTO_MOBILE 55
+
+/** Transport Layer Security Protocol
+using Kryptonet key management interenet protocol number.
+ */
+#define IPPROTO_TLSP 56
+
+/** SKIP interenet protocol number.
+ */
+#define IPPROTO_SKIP 57
+
+/** ICMP for IPv6 interenet protocol number.
+ */
+#define IPPROTO_IPv6_ICMP 58
+
+/** No Next Header for IPv6 interenet protocol number.
+ */
+#define IPPROTO_IPv6_NoNxt 59
+
+/** Destination Options for IPv6 interenet protocol number.
+ */
+#define IPPROTO_IPv6_Opts 60
+
+/** Any host internal protocol interenet protocol number.
+ */
+#define IPPROTO_AHIP 61
+
+/** CFTP interenet protocol number.
+ */
+#define IPPROTO_CFTP 62
+
+/** Any local network interenet protocol number.
+ */
+#define IPPROTO_ALN 63
+
+/** SATNET and Backroom EXPAK interenet protocol number.
+ */
+#define IPPROTO_SAT_EXPAK 64
+
+/** Kryptolan interenet protocol number.
+ */
+#define IPPROTO_KRYPTOLAN 65
+
+/** MIT Remote Virtual Disk Protocol interenet protocol number.
+ */
+#define IPPROTO_RVD 66
+
+/** Internet Pluribus Packet Core interenet protocol number.
+ */
+#define IPPROTO_IPPC 67
+
+/** Any distributed file system interenet protocol number.
+ */
+#define IPPROTO_ADFS 68
+
+/** SATNET Monitoring interenet protocol number.
+ */
+#define IPPROTO_SAT_MON 69
+
+/** VISA Protocol interenet protocol number.
+ */
+#define IPPROTO_VISA 70
+
+/** Internet Packet Core Utility interenet protocol number.
+ */
+#define IPPROTO_IPCV 71
+
+/** Computer Protocol Network Executive interenet protocol number.
+ */
+#define IPPROTO_CPNX 72
+
+/** Computer Protocol Heart Beat interenet protocol number.
+ */
+#define IPPROTO_CPHB 73
+
+/** Wang Span Network interenet protocol number.
+ */
+#define IPPROTO_WSN 74
+
+/** Packet Video Protocol interenet protocol number.
+ */
+#define IPPROTO_PVP 75
+
+/** Backroom SATNET Monitoring interenet protocol number.
+ */
+#define IPPROTO_BR_SAT_MON 76
+
+/** SUN ND IPPROTOCOL_Temporary interenet protocol number.
+ */
+#define IPPROTO_SUN_ND 77
+
+/** WIDEBAND Monitoring interenet protocol number.
+ */
+#define IPPROTO_WB_MON 78
+
+/** WIDEBAND EXPAK interenet protocol number.
+ */
+#define IPPROTO_WB_EXPAK 79
+
+/** ISO Internet Protocol interenet protocol number.
+ */
+#define IPPROTO_ISO_IP 80
+
+/** VMTP interenet protocol number.
+ */
+#define IPPROTO_VMTP 81
+
+/** SECURE-VMTP interenet protocol number.
+ */
+#define IPPROTO_SECURE_VMTP 82
+
+/** VINES interenet protocol number.
+ */
+#define IPPROTO_VINES 83
+
+/** TTP interenet protocol number.
+ */
+#define IPPROTO_TTP 84
+
+/** NSFNET-IGP interenet protocol number.
+ */
+#define IPPROTO_NSFNET_IGP 85
+
+/** Dissimilar Gateway Protocol interenet protocol number.
+ */
+#define IPPROTO_DGP 86
+
+/** TCF interenet protocol number.
+ */
+#define IPPROTO_TCF 87
+
+/** EIGRP interenet protocol number.
+ */
+#define IPPROTO_EIGRP 88
+
+/** OSPFIGP interenet protocol number.
+ */
+#define IPPROTO_OSPFIGP 89
+
+/** Sprite RPC Protocol interenet protocol number.
+ */
+#define IPPROTO_Sprite_RPC 90
+
+/** Locus Address Resolution Protocol interenet protocol number.
+ */
+#define IPPROTO_LARP 91
+
+/** Multicast Transport Protocol interenet protocol number.
+ */
+#define IPPROTO_MTP 92
+
+/** AX.25 Frames interenet protocol number.
+ */
+#define IPPROTO_AX25 93
+
+/** IP-within-IP Encapsulation Protocol interenet protocol number.
+ */
+#define IPPROTO_IPIP 94
+
+/** Mobile Internetworking Control Pro. interenet protocol number.
+ */
+#define IPPROTO_MICP 95
+
+/** Semaphore Communications Sec. Pro. interenet protocol number.
+ */
+#define IPPROTO_SCC_SP 96
+
+/** Ethernet-within-IP Encapsulation interenet protocol number.
+ */
+#define IPPROTO_ETHERIP 97
+
+/** Encapsulation Header interenet protocol number.
+ */
+#define IPPROTO_ENCAP 98
+
+/** Any private encryption scheme interenet protocol number.
+ */
+#define IPPROTO_APES 99
+
+/** GMTP interenet protocol number.
+ */
+#define IPPROTO_GMTP 100
+
+/** Ipsilon Flow Management Protocol interenet protocol number.
+ */
+#define IPPROTO_IFMP 101
+
+/** PNNI over IP interenet protocol number.
+ */
+#define IPPROTO_PNNI 102
+
+/** Protocol Independent Multicast interenet protocol number.
+ */
+#define IPPROTO_PIM 103
+
+/** ARIS interenet protocol number.
+ */
+#define IPPROTO_ARIS 104
+
+/** SCPS interenet protocol number.
+ */
+#define IPPROTO_SCPS 105
+
+/** QNX interenet protocol number.
+ */
+#define IPPROTO_QNX 106
+
+/** Active Networks interenet protocol number.
+ */
+#define IPPROTO_AN 107
+
+/** IP Payload Compression Protocol interenet protocol number.
+ */
+#define IPPROTO_IPComp 108
+
+/** Sitara Networks Protocol interenet protocol number.
+ */
+#define IPPROTO_SNP 109
+
+/** Compaq Peer Protocol interenet protocol number.
+ */
+#define IPPROTO_Compaq_Peer 110
+
+/** IPX in IP interenet protocol number.
+ */
+#define IPPROTO_IPX_in_IP 111
+
+/** Virtual Router Redundancy Protocol interenet protocol number.
+ */
+#define IPPROTO_VRRP 112
+
+/** PGM Reliable Transport Protocol interenet protocol number.
+ */
+#define IPPROTO_PGM 113
+
+/** Any 0-hop protocol interenet protocol number.
+ */
+#define IPPROTO_A0HP 114
+
+/** Layer Two Tunneling Protocol interenet protocol number.
+ */
+#define IPPROTO_L2TP 115
+
+/** D-II Data Exchange (DDX) interenet protocol number.
+ */
+#define IPPROTO_DDX 116
+
+/** Interactive Agent Transfer Protocol interenet protocol number.
+ */
+#define IPPROTO_IATP 117
+
+/** Schedule Transfer Protocol interenet protocol number.
+ */
+#define IPPROTO_STP 118
+
+/** SpectraLink Radio Protocol interenet protocol number.
+ */
+#define IPPROTO_SRP 119
+
+/** UTI interenet protocol number.
+ */
+#define IPPROTO_UTI 120
+
+/** Simple Message Protocol interenet protocol number.
+ */
+#define IPPROTO_SMP 121
+
+/** SM interenet protocol number.
+ */
+#define IPPROTO_SM 122
+
+/** Performance Transparency Protocol interenet protocol number.
+ */
+#define IPPROTO_PTP 123
+
+/** ISIS over IPv4 interenet protocol number.
+ */
+#define IPPROTO_ISIS 124
+
+/** FIRE interenet protocol number.
+ */
+#define IPPROTO_FIRE 125
+
+/** Combat Radio Transport Protocol interenet protocol number.
+ */
+#define IPPROTO_CRTP 126
+
+/** Combat Radio User Datagram interenet protocol number.
+ */
+#define IPPROTO_CRUDP 127
+
+/** SSCOPMCE interenet protocol number.
+ */
+#define IPPROTO_SSCOPMCE 128
+
+/** IPLT interenet protocol number.
+ */
+#define IPPROTO_IPLT 129
+
+/** Secure Packet Shield interenet protocol number.
+ */
+#define IPPROTO_SPS 130
+
+/** Private IP Encapsulation within IP interenet protocol number.
+ */
+#define IPPROTO_PIPE 131
+
+/** Stream Control Transmission Protocol interenet protocol number.
+ */
+#define IPPROTO_SCTP 132
+
+/** Fibre Channel interenet protocol number.
+ */
+#define IPPROTO_FC 133
+
+/** RSVP-E2E-IGNORE interenet protocol number.
+ */
+#define IPPROTO_RSVP_E2E_IGNORE 134
+
+/** Mobility Header interenet protocol number.
+ */
+#define IPPROTO_MH 135
+
+/** UDPLite interenet protocol number.
+ */
+#define IPPROTO_UDPLITE 136
+
+/** MPLS-in-IP interenet protocol number.
+ */
+#define IPPROTO_MPLS_in_IP 137
+
+/** MANET Protocols interenet protocol number.
+ */
+#define IPPROTO_manet 138
+
+/** Host Identity Protocol interenet protocol number.
+ */
+#define IPPROTO_HIP 139
+
+/** Raw interenet protocol number.
+ */
+#define IPPROTO_RAW 255
+
+/** Maximum interenet protocol number.
+ */
+#define IPPROTO_MAX ( IPPROTO_RAW + 1 )
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/protocols.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/include/socket.h
===================================================================
--- network/uspace/srv/net/include/socket.h (nonexistent)
+++ network/uspace/srv/net/include/socket.h (revision 3846)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2008 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
+ * Common socket constants.
+ * Based on the linux src/include/linux/socket.h header file.
+ */
+
+#ifndef __NET_SOCKET_H__
+#define __NET_SOCKET_H__
+
+/* Supported address families. */
+/** Unspecified address family.
+ */
+#define AF_UNSPEC 0
+
+/** Unix domain sockets address family.
+ */
+#define AF_UNIXL 1
+
+/** POSIX name for AF_UNIX address family.
+ */
+#define AF_LOCAL 1
+
+/** Internet IP Protocol address family.
+ */
+#define AF_INET 2
+
+/** Amateur Radio AX.25 address family.
+ */
+#define AF_AX25 3
+
+/** Novell IPX address family.
+ */
+#define AF_IPX 4
+
+/** AppleTalk DDP address family.
+ */
+#define AF_APPLETALK 5
+
+/** Amateur Radio NET/ROM address family.
+ */
+#define AF_NETROM 6
+
+/** Multiprotocol bridge address family.
+ */
+#define AF_BRIDGE 7
+
+/** ATM PVCs address family.
+ */
+#define AF_ATMPVC 8
+
+/** Reserved for X.25 project address family.
+ */
+#define AF_X25 9
+
+/** IP version 6 address family.
+ */
+#define AF_INET6 10
+
+/** Amateur Radio X.25 PLP address family.
+ */
+#define AF_ROSE 11
+
+/** Reserved for DECnet project address family.
+ */
+#define AF_DECnet 12
+
+/** Reserved for 802.2LLC project address family.
+ */
+#define AF_NETBEUI 13
+
+/** Security callback pseudo AF address family.
+ */
+#define AF_SECURITY 14
+
+/** PF_KEY key management API address family.
+ */
+#define AF_KEY 15
+
+/** Alias to emulate 4.4BSD address family.
+ */
+#define AF_NETLINK 16
+
+/** Packet family address family.
+ */
+#define AF_PACKET 17
+
+/** Ash address family.
+ */
+#define AF_ASH 18
+
+/** Acorn Econet address family.
+ */
+#define AF_ECONET 19
+
+/** ATM SVCs address family.
+ */
+#define AF_ATMSVC 20
+
+/** Linux SNA Project (nutters!) address family.
+ */
+#define AF_SNA 22
+
+/** IRDA sockets address family.
+ */
+#define AF_IRDA 23
+
+/** PPPoX sockets address family.
+ */
+#define AF_PPPOX 24
+
+/** Wanpipe API Sockets address family.
+ */
+#define AF_WANPIPE 25
+
+/** Linux LLC address family.
+ */
+#define AF_LLC 26
+
+/** Controller Area Network address family.
+ */
+#define AF_CAN 29
+
+/** TIPC sockets address family.
+ */
+#define AF_TIPC 30
+
+/** Bluetooth sockets address family.
+ */
+#define AF_BLUETOOTH 31
+
+/** IUCV sockets address family.
+ */
+#define AF_IUCV 32
+
+/** RxRPC sockets address family.
+ */
+#define AF_RXRPC 33
+
+/** Maximum address family.
+ */
+#define AF_MAX 34
+
+/* Protocol families, same as address families. */
+/*
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_LOCAL AF_LOCAL
+#define PF_INET AF_INET
+#define PF_AX25 AF_AX25
+#define PF_IPX AF_IPX
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NETROM AF_NETROM
+#define PF_BRIDGE AF_BRIDGE
+#define PF_ATMPVC AF_ATMPVC
+#define PF_X25 AF_X25
+#define PF_INET6 AF_INET6
+#define PF_ROSE AF_ROSE
+#define PF_DECnet AF_DECnet
+#define PF_NETBEUI AF_NETBEUI
+#define PF_SECURITY AF_SECURITY
+#define PF_KEY AF_KEY
+#define PF_NETLINK AF_NETLINK
+#define PF_ROUTE AF_ROUTE
+#define PF_PACKET AF_PACKET
+#define PF_ASH AF_ASH
+#define PF_ECONET AF_ECONET
+#define PF_ATMSVC AF_ATMSVC
+#define PF_SNA AF_SNA
+#define PF_IRDA AF_IRDA
+#define PF_PPPOX AF_PPPOX
+#define PF_WANPIPE AF_WANPIPE
+#define PF_LLC AF_LLC
+#define PF_CAN AF_CAN
+#define PF_TIPC AF_TIPC
+#define PF_BLUETOOTH AF_BLUETOOTH
+#define PF_IUCV AF_IUCV
+#define PF_RXRPC AF_RXRPC
+#define PF_MAX AF_MAX
+*/
+/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
+/*#define SOL_IP 0
+#define SOL_ICMP 1
+#define SOL_TCP 6
+#define SOL_UDP 17
+#define SOL_IPV6 41
+#define SOL_ICMPV6 58
+#define SOL_SCTP 132
+#define SOL_UDPLITE 136 *//* UDP-Lite (RFC 3828) */
+/*#define SOL_RAW 255
+#define SOL_IPX 256
+#define SOL_AX25 257
+#define SOL_ATALK 258
+#define SOL_NETROM 259
+#define SOL_ROSE 260
+#define SOL_DECNET 261
+#define SOL_X25 262
+#define SOL_PACKET 263
+#define SOL_ATM 264 *//* ATM layer (cell level) */
+/*#define SOL_AAL 265 *//* ATM Adaption Layer (packet level) */
+/*#define SOL_IRDA 266
+#define SOL_NETBEUI 267
+#define SOL_LLC 268
+#define SOL_DCCP 269
+#define SOL_NETLINK 270
+#define SOL_TIPC 271
+#define SOL_RXRPC 272
+#define SOL_PPPOL2TP 273
+#define SOL_BLUETOOTH 274
+*/
+//
+/** IPX options.
+// */
+//#define IPX_TYPE 1
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/include/socket.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/tcp/tcp_module.h
===================================================================
--- network/uspace/srv/net/tcp/tcp_module.h (nonexistent)
+++ network/uspace/srv/net/tcp/tcp_module.h (revision 3846)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup net
+ * @{
+ */
+
+/**
+ * @file
+ */
+
+#ifndef __NET_TCP_MODULE_H__
+#define __NET_TCP_MODULE_H__
+
+#include <ipc/ipc.h>
+
+int tcp_initialize( void );
+int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/tcp/tcp_module.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/tcp/tcp.c
===================================================================
--- network/uspace/srv/net/tcp/tcp.c (revision 3845)
+++ network/uspace/srv/net/tcp/tcp.c (revision 3846)
@@ -34,17 +34,20 @@
*/
#include <async.h>
-#include <errno.h>
#include <stdio.h>
+
#include <ipc/ipc.h>
#include <ipc/services.h>
-//#include <sys/mman.h>
#include "../err.h"
#include "../messages.h"
#include "../modules.h"
+#include "../packet.h"
+#include "../ip/ip_messages.h"
+
#include "tcp.h"
+#include "tcp_module.h"
tcp_globals_t tcp_globals;
@@ -53,23 +56,26 @@
int tcp_initialize( void ){
ERROR_DECLARE;
-/* ipcarg_t arg1, arg2;
+ ipcarg_t arg1, arg2;
+ packet_t packet;
- printf( "\nTCP - testing to send IP:\t" );
- ERROR_PROPAGATE( ip_message( NET_IP_ECHO, 12, 34, NULL, & arg1, & arg2, NULL ));
+ 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" );
-*/
- ERROR_PROPAGATE( ip_message( NET_IP_TCP_REGISTER, SERVICE_TCP, NULL, NULL, NULL, NULL, NULL ));
- return EOK;
-}
-int tcp_call( ipc_callid_t callid ){
+ printf( "\nTCP - testing to send packet to IP:\t" );
+ packet = packet_create( 20, 30, 20 );
+ if( ! packet ) return ENOMEM;
+ packet_copy_data( packet, "Hi, this is TCP", 16 );
+ ERROR_PROPAGATE( ip_send( tcp_globals.ip_phone, -1, packet ));
+ printf( "\tOK\n" );
return EOK;
}
-int tcp_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
- switch( method ){
+int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+ * answer_count = 0;
+ switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
}
/branches/network/uspace/srv/net/tcp/tcp.h
34,19 → 34,9
* @file
*/
 
#ifndef __NET_TCP_INTERNALS_H__
#define __NET_TCP_INTERNALS_H__
#ifndef __NET_TCP_H__
#define __NET_TCP_H__
 
#ifdef NETWORKING_modular
#define ip_message( ... ) ipc_call_sync_3_3( tcp_globals.ip_phone, __VA_ARGS__ )
#else
#ifdef NETWORKING_module
 
#include "../ip/ip.h"
 
#endif
#endif
 
typedef struct tcp_globals tcp_globals_t;
 
struct tcp_globals{
54,10 → 44,6
int networking_phone;
};
 
int tcp_initialize( void );
int tcp_call( ipc_callid_t callid );
int tcp_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/tcp/tcp_module.c
35,17 → 35,22
 
#include <async.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../err.h"
#include "../modules.h"
 
#include "../include/protocols.h"
 
#include "tcp.h"
#include "tcp_module.h"
 
#define NAME "TCP protocol"
 
void tcp_print_name( void );
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
int tcp_start_module( async_client_conn_t client_connection );
 
extern tcp_globals_t tcp_globals;
 
53,17 → 58,20
printf( NAME );
}
 
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){
services_t need[ 3 ];
int * need_phone[ 3 ];
int tcp_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
need[ 0 ] = SERVICE_IP;
need[ 1 ] = SERVICE_NETWORKING;
need[ 2 ] = NULL;
need_phone[ 0 ] = & tcp_globals.ip_phone;
need_phone[ 1 ] = & tcp_globals.networking_phone;
need_phone[ 2 ] = NULL;
return start_service( SERVICE_TCP, need, need_phone, client_connection, tcp_initialize );
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
tcp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
tcp_globals.ip_phone = bind_service( SERVICE_IP, IPPROTO_TCP, 0, 0, client_connection );
ERROR_PROPAGATE( tcp_initialize());
ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
 
async_manager();
 
return EOK;
}
 
/** @}
/branches/network/uspace/srv/net/tcp/Makefile
45,9 → 45,10
$(NAME)_module.c \
$(NAME).c \
../module.c \
../modules.c
../modules.c \
../packet.c
 
DEFS += -D NETWORKING_$(NETWORKING) -D $(NAME)_call=module_call -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
DEFS += -D TCP_BUNDLE=1 -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
/branches/network/uspace/srv/net/modules.c
33,6 → 33,7
/** @file
*/
#include <async.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
53,34 → 54,21
return phone;
}
 
int start_service( services_t me, services_t need[], int * need_phone[], void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ), int ( * initialize_me )( void )){
ipcarg_t phonehash;
int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ){
ERROR_DECLARE;
 
if( ! client_connection ) return EINVAL;
async_set_client_connection( client_connection );
ipcarg_t phone;
ipcarg_t phonehash;
 
if( need ){
if( ! need_phone ) return EINVAL;
while( * need ){
if( ! * need_phone ) return EINVAL;
 
/* Connect to the needed service */
** need_phone = connect_to_service( * need );
++ need;
++ need_phone;
phone = connect_to_service( need );
if( phone >= 0 ){
if( ERROR_OCCURED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
async_msg_0( phone, IPC_M_PHONE_HUNGUP );
return ERROR_CODE;
}
async_new_connection( phonehash, 0, NULL, client_receiver );
}
 
/* Initialize service by its callback */
if( initialize_me ) ERROR_PROPAGATE( initialize_me());
 
/* Register service at NS */
if( me ) ERROR_PROPAGATE( REGISTER_ME( me, & phonehash ));
 
async_manager();
 
return EOK;
return phone;
}
 
/** @}
/branches/network/uspace/srv/net/packet_queue.c
0,0 → 1,109
/*
* Copyright (c) 2008 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 <malloc.h>
 
#include "configuration.h"
#include "packet.h"
#include "packet_queue.h"
 
#define PQ_MAGIC_VALUE 0x23465968;
 
static inline int pq_is_valid( pq_item_ref item );
 
pq_item_ref pq_add( pq_head * queue, packet_t packet, int order, size_t metric ){
pq_item_ref item;
pq_item_ref tmp;
 
tmp = pq_create( packet, order, metric );
if( ! tmp ) return NULL;
item = queue;
while( pq_is_valid( item )){
if( item->order < order ){
if( item->next && pq_is_valid( item->next )){
item = item->next;
}else{
item->next = tmp;
tmp->previous = item;
return tmp;
}
}else{
tmp->previous = item->previous;
tmp->next = item;
item->previous = tmp;
if( tmp->previous ){
tmp->previous->next = tmp;
}else{
* queue = tmp;
}
return tmp;
}
}
}
 
 
pq_head pq_create( packet_t packet, int order, size_t metric ){
pq_item_ref item;
 
item = ( pq_item_ref ) malloc( sizeof( pq_item_t ));
if( ! item ) return NULL;
item->order = order;
item->metric = metric;
item->packet = packet;
item->previous = NULL;
item->next = NULL;
item->magic_value = PQ_MAGIC_VALUE;
return item;
}
 
void pq_destroy( pq_head queue ){
pq_item_ref actual;
pq_item_ref next;
 
actual = queue;
while( pq_is_valid( actual )){
next = actual->next;
actual->magic_value = 0;
free( actual );
actual = next;
}
}
 
static inline int pq_is_valid( pq_item_ref item ){
return item && ( item->magic_value == PQ_MAGIC_VALUE );
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/configuration.h
===================================================================
--- network/uspace/srv/net/configuration.h (revision 3845)
+++ network/uspace/srv/net/configuration.h (revision 3846)
@@ -27,20 +27,48 @@
*/
/** @addtogroup net
- * @{
+ * @{
*/
/** @file
+ * A&nbsp;networking subsystem compilation configuration file.
*/
#ifndef __NET_CONFIGURATION_H__
#define __NET_CONFIGURATION_H__
-#define NET_SELF_TEST 0
+/** An&nbsp;option to activate the self test.
+ */
+#define NET_SELF_TEST 0
+
+/** An&nbsp;option to activate the measured strings self test.
+ * The option NET_SELF_TEST has to be activated.
+ * @see measured_strings.h
+ */
#define NET_SELF_TEST_MEASURED_STRINGS 1
-#define NET_SELF_TEST_CHAR_MAP 0
-#define NET_SELF_TEST_INT_MAP 0
-#define NET_SELF_TEST_GENERIC_FIELD 0
+
+/** An&nbsp;option to activate the char map self test.
+ * The option NET_SELF_TEST has to be activated.
+ * @see char_map.h
+ */
+#define NET_SELF_TEST_CHAR_MAP 0
+
+/** An&nbsp;option to activate the integral map self test.
+ * The option NET_SELF_TEST has to be activated.
+ * @see int_map.h
+ */
+#define NET_SELF_TEST_INT_MAP 0
+
+/** An&nbsp;option to activate the generic field self test.
+ * The option NET_SELF_TEST has to be activated.
+ * @see generic_field.h
+ */
+#define NET_SELF_TEST_GENERIC_FIELD 0
+
+/** An&nbsp;option to activate the generic char map self test.
+ * The option NET_SELF_TEST has to be activated.
+ * @see generic_char_map.h
+ */
#define NET_SELF_TEST_GENERIC_CHAR_MAP 0
#endif
/branches/network/uspace/srv/net/messages.h
33,13 → 33,16
/** @file
*/
 
#define NET_NETIF_COUNT 7
#define NET_NETWORKING_COUNT 4
#define NET_LL_COUNT 5
#define NET_ETHERNET_COUNT 0
#define NET_IL_COUNT 2
#define NET_IP_COUNT 4
#define NET_ARP_COUNT 0
#ifndef __NET_MESSAGES_H__
#define __NET_MESSAGES_H__
 
#define NET_NETIF_COUNT 6
#define NET_NET_COUNT 9
#define NET_NIL_COUNT 8
#define NET_ETH_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
#define NET_UDP_COUNT 0
51,15 → 54,15
#define NET_NETIF_FIRST NET_FIRST
#define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT )
 
#define NET_NETWORKING_FIRST ( NET_NETIF_LAST + 0 )
#define NET_NETWORKING_LAST ( NET_NETWORKING_FIRST + NET_NETWORKING_COUNT )
#define NET_NET_FIRST ( NET_NETIF_LAST + 0 )
#define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT )
 
#define NET_LL_FIRST ( NET_NETWORKING_LAST + 0 )
#define NET_LL_LAST ( NET_LL_FIRST + NET_LL_COUNT )
#define NET_ETHERNET_FIRST ( NET_LL_LAST + 0 )
#define NET_ETHERNET_LAST ( NET_ETHERNET_FIRST + NET_ETHERNET_COUNT )
#define NET_NIL_FIRST ( NET_NET_LAST + 0 )
#define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT )
#define NET_ETH_FIRST ( NET_NIL_LAST + 0 )
#define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT )
 
#define NET_IL_FIRST ( NET_ETHERNET_LAST + 0 )
#define NET_IL_FIRST ( NET_ETH_LAST + 0 )
#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 )
85,9 → 88,9
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
 
#define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_FIRST, NET_LAST )
#define IS_NET_NETWORKING_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NETWORKING_FIRST, NET_NETWORKING_LAST )
#define IS_NET_LL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_LL_FIRST, NET_LL_LAST )
#define IS_NET_ETHERNET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ETHERNET_FIRST, NET_SOCKET_LAST )
#define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NET_FIRST, NET_NET_LAST )
#define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NIL_FIRST, NET_NIL_LAST )
#define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ETH_FIRST, NET_ETH_LAST )
#define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_IL_FIRST, NET_IL_LAST )
#define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_IP_FIRST, NET_IP_LAST )
#define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ARP_FIRST, NET_ARP_LAST )
97,29 → 100,75
#define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
 
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,
NET_NETIF_REGISTER,
/* ( device_id ), packet_send */
NET_NETIF_SEND,
/* ( device_id ) */
NET_NETIF_START,
/* ( device_id ), ipc_data_read( stats ) */
NET_NETIF_STATS,
/* ( device_id ) */
NET_NETIF_STOP,
NET_NETWORKING_DEVICE = NET_NETWORKING_FIRST,
NET_NETWORKING_GET_CONFIGURATION,
NET_NETWORKING_GET_DEVICE_CONFIGURATION,
NET_NETWORKING_STARTUP,
NET_LL_DEVICE = NET_LL_FIRST,
NET_LL_DEVICE_STATE_CHANGED,
NET_LL_MTU_CHANGED,
NET_LL_RECEIVED,
NET_LL_REGISTER,
/* () not supported, registers new device */
NET_NET_DEVICE = NET_NET_FIRST,
/* (), measured_strings_send( names ), measured_strings_return( values ) */
NET_NET_GET_CONF,
/* ( device_id ), measured_strings_send( names ), measured_strings_return( values ) */
NET_NET_GET_DEVICE_CONF,
/* () not supported, measured_strings_send( names ), measured_strings_send( values ) */
NET_NET_SET_CONF,
/* ( device_id ) not supported, measured_strings_send( names ), measured_strings_send( values ) */
NET_NET_SET_DEVICE_CONF,
/* () */
NET_NET_STARTUP,
/* ( device_id ) */
NET_NET_START,
/* ( device_id ) */
NET_NET_STOP,
/* ( device_id ) ipc_data_read( stats ) */
NET_NET_STATS,
/* ( device_id, driver_service ) */
NET_NIL_DEVICE = NET_NIL_FIRST,
/* ( device_id, state ) */
NET_NIL_DEVICE_STATE,
/* ( device_id, mtu ) */
NET_NIL_MTU,
/* ( device_id ), packet_send */
NET_NIL_RECEIVED,
/* ( device_id ), packet_send */
NET_NIL_SEND,
/* ( device_id ) -> prefix, content, sufix */
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,
/* ( service ), protocol */
// NET_NIL_PROTOCOL,
/* ( device_id, nil_service ) */
NET_IL_DEVICE = NET_IL_FIRST,
NET_IL_DEVICE_STATE_CHANGED,
NET_IP_CONFIGURATION_DHCP = NET_IP_FIRST,
NET_IP_CONFIGURATION_STATIC,
NET_IP_ECHO,
NET_IP_TCP_REGISTER
/* ( 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,
NET_IP_SEND,
/* ( 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
} net_message;
 
#endif
 
/** @}
*/
/branches/network/uspace/srv/net/modules.h
33,13 → 33,22
/** @file
*/
 
#include <async.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
/** Converts the data length between different types.
* @param type_from The source type. Input parameter.
* @param type_to The destination type. Input parameter.
* @param count The number units of the source type size. Input parameter.
*/
#define CONVERT_SIZE( type_from, type_to, count ) (( sizeof( type_from ) / sizeof( type_to )) * ( count ))
 
#define REGISTER_ME( me, phonehash ) ipc_connect_to_me( PHONE_NS, ( me ), 0, 0, ( phonehash ))
 
int connect_to_service( services_t need );
int start_service( services_t me, services_t need[], int * need_phone[], void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ), int ( * initialize_me )( void ));
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 );
 
/** @}
*/
/branches/network/uspace/srv/net/measured_strings.c
27,11 → 27,12
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/**
* @file
/** @file
* A&nbsp;character string with measured length implementation file.
* @see measured_strings.h
*/
 
#include <errno.h>
39,6 → 40,7
#include <stdio.h>
#include <string.h>
#include <unistd.h>
 
#include <ipc/ipc.h>
 
#include "err.h"
45,7 → 47,13
#include "measured_strings.h"
#include "modules.h"
 
size_t * prepare_lengths( measured_string_ref strings, size_t count );
/** Computes the lengths of the measured strings in the given array.
* @param strings The measured strings array to be processed. Input parameter.
* @param count The measured strings array size. Input parameter.
* @returns The computed sizes array.
* @returns NULL if there is no memory left.
*/
size_t * prepare_lengths( const measured_string_ref strings, size_t count );
 
measured_string_ref measured_string_create_bulk( const char * string, size_t length ){
measured_string_ref new;
57,7 → 65,9
if( ! new ) return NULL;
new->length = length;
new->value = (( char * ) new ) + sizeof( measured_string_t );
memcpy( new->value, string, new->length + 1 );
// append terminating zero explicitly - to be safe
memcpy( new->value, string, new->length );
new->value[ new->length ] = '\0';
return new;
}
 
64,10 → 74,10
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
size_t length;
char * next;
size_t * lengths;
int index;
size_t length;
char * next;
ipc_callid_t callid;
 
if(( ! strings ) || ( ! data ) || ( count <= 0 )){
117,12 → 127,12
return EOK;
}
 
int measured_strings_reply( measured_string_ref strings, size_t count ){
int measured_strings_reply( const measured_string_ref strings, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
size_t length;
size_t * lengths;
int index;
size_t length;
ipc_callid_t callid;
 
if(( ! strings ) || ( count <= 0 )){
156,7 → 166,7
ERROR_DECLARE;
 
size_t * lengths;
int index;
int index;
char * next;
 
if(( phone <= 0 ) || ( ! strings ) || ( ! data ) || ( count <= 0 )){
193,11 → 203,11
return EOK;
}
 
int measured_strings_send( int phone, measured_string_ref strings, size_t count ){
int measured_strings_send( int phone, const measured_string_ref strings, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
int index;
 
if(( phone <= 0 ) || ( ! strings ) || ( count <= 0 )){
return EINVAL;
217,9 → 227,9
return EOK;
}
 
size_t * prepare_lengths( measured_string_ref strings, size_t count ){
size_t * prepare_lengths( const measured_string_ref strings, size_t count ){
size_t * lengths;
int index;
int index;
size_t length;
 
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 ));
/branches/network/uspace/srv/net/packet_queue.h
0,0 → 1,61
/*
* Copyright (c) 2008 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*/
 
#ifndef __NET_PACKET_QUEUE__
#define __NET_PACKET_QUEUE__
 
#include "packet.h"
 
typedef struct pq_item pq_item_t;
typedef pq_item * pq_item_ref;
typedef pq_item_ref pq_head_t;
typedef pq_head * pq_head_ref;
 
struct pq_item{
int order;
size_t metric;
packet_t packet;
pq_item_ref previous;
pq_item_ref next;
};
 
pq_head_t pq_create( packet_t packet, int order, size_t metric );
pq_item_ref pq_add( pq_head_ref queue, packet_t packet, int order, size_t metric );
void pq_destroy( pq_head_t queue );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/measured_strings.h
===================================================================
--- network/uspace/srv/net/measured_strings.h (revision 3845)
+++ network/uspace/srv/net/measured_strings.h (revision 3846)
@@ -27,30 +27,108 @@
*/
/** @addtogroup net
- * @{
+ * @{
*/
-/**
- * @file
+/** @file
+ * A&nbsp;character string with measured length header file.
+ * This structure has been designed for serialization of character strings between modules.
*/
#ifndef __MEASURED_STRINGS_H__
#define __MEASURED_STRINGS_H__
+/** A&nbsp;type definition of a&nbsp;character string with measured length.
+ * @see measured_string
+ */
typedef struct measured_string measured_string_t;
-typedef measured_string_t * measured_string_ref;
+/** A&nbsp;type definition of a&nbsp;character string with measured length pointer.
+ * @see measured_string
+ */
+typedef measured_string_t * measured_string_ref;
+
+/** A&nbsp;character string with measured length.
+ * This structure has been designed for serialization of character strings between modules.
+ */
struct measured_string{
+
+ /** The character string data.
+ */
char * value;
+
+ /** The character string length.
+ */
size_t length;
};
+/** Creates a&nbsp;new measured string bundled with a&nbsp;copy of the given string itself as one memory block.
+ * If the measured string is being freed, whole memory block is freed.
+ * The measured string should be used only as a&nbsp;constant.
+ * @param string The initial character string to be stored. Input parameter.
+ * @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\0') character otherwise. Input parameter.
+ * @returns The new bundled charecter string with measured length.
+ * @returns NULL if there is no memory left.
+ */
measured_string_ref measured_string_create_bulk( const char * string, size_t length );
-int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count );
-int measured_strings_reply( measured_string_ref strings, size_t count );
-int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count );
-int measured_strings_send( int phone, measured_string_ref strings, size_t count );
+/** Receives a&nbsp;measured strings array from a&nbsp;calling module.
+ * Creates the array and the data memory blocks.
+ * This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
+ * @param strings The received measured strings array. Output parameter.
+ * @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
+ * @param count The size of the measured strings array. Input parameter.
+ * @returns EOK on success.
+ * @returns EINVAL if the strings or data parameter is NULL.
+ * @returns EINVAL if the count parameter is zero (0).
+ * @returns EINVAL if the sent array differs in size.
+ * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
+ * @returns ENOMEM if there is no memory left.
+ * @returns Other error codes as defined for the ipc_data_write_finalize() function.
+ */
+int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count );
+
+/** Replies the given measured strings array to a&nbsp;calling module.
+ * This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
+ * @param strings The measured strings array to be transferred. Input parameter.
+ * @param count The measured strings array size. Input parameter.
+ * @returns EOK on success.
+ * @returns EINVAL if the strings parameter is NULL.
+ * @returns EINVAL if the count parameter is zero (0).
+ * @returns EINVAL if the calling module does not accept the given array size.
+ * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
+ * @returns Other error codes as defined for the ipc_data_read_finalize() function.
+ */
+int measured_strings_reply( const measured_string_ref strings, size_t count );
+
+/** Receives a&nbsp;measured strings array from another module.
+ * Creates the array and the data memory blocks.
+ * This method should be used only following other IPC messages as the array size has to be negotiated in advance.
+ * @param phone The other module phone. Input parameter.
+ * @param strings The returned measured strings array. Output parameter.
+ * @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
+ * @param count The size of the measured strings array. Input parameter.
+ * @returns EOK on success.
+ * @returns EINVAL if the strings or data parameter is NULL.
+ * @returns EINVAL if the phone or count parameter is not positive (<=0).
+ * @returns EINVAL if the sent array differs in size.
+ * @returns ENOMEM if there is no memory left.
+ * @returns Other error codes as defined for the ipc_data_read_start() function.
+ */
+int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count );
+
+/** Sends the given measured strings array to another module.
+ * This method should be used only following other IPC messages as the array size has to be negotiated in advance.
+ * @param phone The other module phone. Input parameter.
+ * @param strings The measured strings array to be transferred. Input parameter.
+ * @param count The measured strings array size. Input parameter.
+ * @returns EOK on success.
+ * @returns EINVAL if the strings parameter is NULL.
+ * @returns EINVAL if the phone or count parameter is not positive (<=0).
+ * @returns Other error codes as defined for the ipc_data_write_start() function.
+ */
+int measured_strings_send( int phone, const measured_string_ref strings, size_t count );
+
#endif
/** @}
/branches/network/uspace/srv/net/module.c
36,40 → 36,62
#include <async.h>
#include <stdio.h>
#include <task.h>
 
#include <ipc/ipc.h>
 
#include "err.h"
#include "modules.h"
 
extern int module_call( ipc_callid_t callid );
extern int module_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
extern int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
extern void module_print_name( void );
extern int module_start( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
extern int module_start( async_client_conn_t client_connection );
 
void client_connection( ipc_callid_t iid, ipc_call_t * icall );
int main( int argc, char * argv[] );
void client_connection( ipc_callid_t iid, ipc_call_t * icall );
int main( int argc, char * argv[] );
 
/** Default thread for new connections.
*/
void client_connection( ipc_callid_t iid, ipc_call_t * icall ){
ipc_callid_t callid;
ipc_call_t call;
ipcarg_t arg1, arg2, arg3;
int res;
ipc_callid_t callid;
ipc_call_t call;
ipc_call_t answer;
int count;
int res;
 
/* Accept the connection */
/*
* Accept the connection
* - Answer the first IPC_M_CONNECT_ME_TO call.
*/
ipc_answer_0( iid, EOK );
 
while( true ){
// refresh data
count = 0;
IPC_SET_RETVAL( answer, 0 );
// just to be precize
IPC_SET_RETVAL( answer, 0 );
IPC_SET_ARG1( answer, 0 );
IPC_SET_ARG2( answer, 0 );
IPC_SET_ARG3( answer, 0 );
IPC_SET_ARG4( answer, 0 );
IPC_SET_ARG5( answer, 0 );
 
callid = async_get_call( & call );
arg1 = 0;
arg2 = 0;
arg3 = 0;
res = module_call( callid );
if( res == EOK ){
res = module_message( callid, IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 );
res = module_message( callid, & call, & answer, & count );
 
switch( count ){
case 0: ipc_answer_0( callid, res );
continue;
case 1: ipc_answer_1( callid, res, IPC_GET_ARG1( answer ));
continue;
case 2: ipc_answer_2( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ));
continue;
case 3: ipc_answer_3( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer ));
continue;
case 4: ipc_answer_4( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer ), IPC_GET_ARG4( answer ));
continue;
default: ipc_answer_5( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer ), IPC_GET_ARG4( answer ), IPC_GET_ARG5( answer ));
continue;
}
ipc_answer_2( callid, res, arg1, arg2 );
}
}
 
/branches/network/uspace/srv/net/ip/ip_module.h
0,0 → 1,48
/*
* Copyright (c) 2008 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_IP_MODULE_H__
#define __NET_IP_MODULE_H__
 
#include <ipc/ipc.h>
 
int ip_initialize( void );
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/ip/ip_messages.h
===================================================================
--- network/uspace/srv/net/ip/ip_messages.h (nonexistent)
+++ network/uspace/srv/net/ip/ip_messages.h (revision 3846)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2008 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup net
+ * @{
+ */
+
+/**
+ * @file
+ */
+
+#ifndef __NET_IP_MESSAGES_H__
+#define __NET_IP_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include "../err.h"
+#include "../messages.h"
+#include "../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 ) \
+ { \
+ ERROR_DECLARE; \
+ \
+ aid_t message; \
+ ipc_call_t answer; \
+ ipcarg_t result; \
+ \
+ message = async_send_1(( ip_phone ), NET_IP_SEND, ( device_id ), & answer ); \
+ if( ERROR_OCCURED( packet_send(( packet ), ( ip_phone )))){ \
+ async_wait_for( message, NULL ); \
+ result = ERROR_CODE; \
+ }else{ \
+ async_wait_for( message, & result ); \
+ } \
+ result; \
+ }
+
+#endif
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/ip/ip_messages.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/ip/ip_header.h
===================================================================
--- network/uspace/srv/net/ip/ip_header.h (nonexistent)
+++ network/uspace/srv/net/ip/ip_header.h (revision 3846)
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2008 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
+ * Interent protocol header and options definitions.
+ * Names according to the linux src/include/linux/ip.h header file.
+ */
+
+#ifndef __NET_IP_HEADER_H__
+#define __NET_IP_HEADER_H__
+
+#include <byteorder.h>
+#include <types.h>
+
+typedef struct ip_header ip_header_t;
+typedef ip_header_t * ip_header_ref;
+
+/** Internet header.
+ * The variable options should be included after the header itself and indicated by the increased header length value.
+ */
+struct ip_header{
+#ifdef ARCH_IS_BIG_ENDIAN
+ /** The Version field indicates the format of the internet header.
+ */
+ uint8_t:4 version;
+ /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
+ * Note that the minimum value for a~correct header is~5.
+ */
+ uint8_t:4 ihl;
+#else
+ /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
+ * Note that the minimum value for a~correct header is~5.
+ */
+ uint8_t:4 ihl;
+ /** The Version field indicates the format of the internet header.
+ */
+ uint8_t:4 version;
+#endif
+ /** The Type of Service provides an indication of the abstract parameters of the quality of service desired.
+ * These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network.
+ * Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load).
+ * The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput.
+ */
+ uint8_t tos;
+ /** Total Length is the length of the datagram, measured in octets, including internet header and data.
+ * This field allows the length of a~datagram to be up to 65,535~octets.
+ */
+ uint16_t total_length;
+ /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.
+ */
+ unit16_t identification;
+#ifdef ARCH_IS_BIG_ENDIAN
+ /** Various control flags.
+ */
+ uint_16:3 flags;
+ /** This field indicates where in the datagram this fragment belongs.
+ */
+ uint_16:13 fragment_offset;
+#else
+ /** This field indicates where in the datagram this fragment belongs.
+ */
+ uint_16:13 fragment_offset;
+ /** Various control flags.
+ */
+ uint_16:3 flags;
+#endif
+ /** This field indicates the maximum time the datagram is allowed to remain in the internet system.
+ * If this field contains the value zero, then the datagram must be destroyed.
+ * This field is modified in internet header processing.
+ * The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist.
+ * The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.
+ */
+ uint8_t ttl;
+ /** This field indicates the next level protocol used in the data portion of the internet datagram.
+ */
+ uint8_t protocol;
+ /** A checksum on the header only.
+ * Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.
+ * The checksum algorithm is: The checksum field is the 16~bit one's complement of the one's complement sum of all 16~bit words in the header.
+ * For purposes of computing the checksum, the value of the checksum field is zero.
+ */
+ uint16_t header_checksum;
+ /** The source address.
+ */
+ uint32_t source_address;
+ /** The destination address.
+ */
+ uint32_t destination_address;
+};
+
+typedef struct ip_option ip_option_t;
+typedef ip_option * ip_option_ref;
+
+/** Internet option header.
+ * Only type field is always valid.
+ * Other fields' validity depends on the option type.
+ */
+struct ip_option{
+ /** A single octet of option-type.
+ */
+ uint8_t type;
+ /** An option length octet.
+ */
+ uint8_t length;
+ /** A~pointer.
+ */
+ uint8_t pointer;
+#ifdef ARCH_IS_BIG_ENDIAN
+ /** The number of IP modules that cannot register timestamps due to lack of space.
+ */
+ uint8_t:4 overflow;
+ /** Various internet timestamp control flags.
+ */
+ uint8_t:4 flags;
+#else
+ /** Various internet timestamp control flags.
+ */
+ uint8_t:4 flags;
+ /** The number of IP modules that cannot register timestamps due to lack of space.
+ */
+ uint8_t:4 overflow;
+#endif
+};
+
+#define IPTOS_TOS_MASK 0x1E
+#define IPTOS_PRECEDENCE_SHIFT 5
+#define IPTOS_DELAY_SHIFT 4
+#define IPTOS_TROUGHPUT_SHIFT 3
+#define IPTOS_RELIABILITY_SHIFT 2
+#define IPTOS_COST_SHIFT 1
+
+#define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT )
+#define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT )
+
+#define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
+#define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
+
+#define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT )
+#define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT )
+
+#define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT )
+#define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT )
+
+#define IPTOS_PREC_MASK 0xE0
+#define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
+#define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
+
+#define IPFLAG_FRAGMENT_SHIFT 1
+#define IPFLAG_FRAGMENTED_SHIFT 0
+
+#define IPFLAG_MAY_FRAGMENT ( 0x0 << IPFLAG_FRAGMENT_SHIFT )
+#define IPFLAG_DONT_FRAGMENT ( 0x1 << IPFLAG_FRAGMENT_SHIFT )
+
+#define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT )
+#define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT )
+
+#define IPOPT_COPY_SHIFT 7
+#define IPOPT_CLASS_SHIFT 5
+#define IPOPT_NUMBER_SHIFT 0
+#define IPOPT_CLASS_MASK 0x60
+#define IPOPT_NUMBER_MASK 0x1F
+
+#define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT )
+
+#define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
+
+#define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY )
+#define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK )
+#define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK )
+
+#define IPOPT_CONTROL ( 1 << IPOPT_CLASS_SHIFT )
+#define IPOPT_RESERVED1 ( 2 << IPOPT_CLASS_SHIFT )
+#define IPOPT_MEASUREMENT ( 3 << IPOPT_CLASS_SHIFT )
+#define IPOPT_RESERVED2 ( 4 << IPOPT_CLASS_SHIFT )
+
+//#define IPOPT_END_OF_LIST 0x0
+#define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
+//#define IPOPT_NO_OPERATION 0x1
+#define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
+//#define IPOPT_SECURITY 0x82
+#define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
+#define IPOPT_SEC_LENGTH 11
+#define IPOPT_SEC_UNCLASIFIED 0x0
+#define IPOPT_SEC_CONFIDENTIAL 0xF035
+#define IPOPT_SEC_EFTO 0x789A
+#define IPOPT_SEC_MMMM 0xBC4D
+#define IPOPT_SEC_PROG 0x5E26
+#define IPOPT_SEC_RESTRICTED 0xAF13
+#define IPOPT_SEC_SECRET 0xD788
+#define IPOPT_SEC_TOP_SECRET 0x6BC5
+//#define IPOPT_LOOSE_SOURCE 0x83
+#define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
+//#define IPOPT_STRICT_SOURCE 0x89
+#define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
+//#define IPOPT_RECORD_ROUTE 0x07
+#define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
+//#define IPOPT_STREAM_IDENTIFIER 0x88
+#define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
+#define IPOPT_SID_LENGTH 4
+//#define IPOPT_INTERNET_TIMESTAMP 0x44
+#define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
+#define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
+
+#define IPVERSION 4
+#define MAXTTL 255
+#define IPDEFTTL 64
+
+#define IPOPT_OPTVAL 0
+#define IPOPT_OLEN 1
+#define IPOPT_OFFSET 2
+#define IPOPT_MINOFF 4
+#define MAX_IPOPTLEN 40
+#define IPOPT_NOP IPOPT_NOOP
+#define IPOPT_EOL IPOPT_END
+#define IPOPT_TS IPOPT_TIMESTAMP
+
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+#endif
+
+/** @}
+ */
/network/uspace/srv/net/ip/ip_header.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/ip/ip.c
===================================================================
--- network/uspace/srv/net/ip/ip.c (revision 3845)
+++ network/uspace/srv/net/ip/ip.c (revision 3846)
@@ -33,58 +33,64 @@
/** @file
*/
+#include <as.h>
#include <async.h>
#include <errno.h>
#include <stdio.h>
+
#include <ipc/ipc.h>
#include <ipc/services.h>
-//#include <sys/mman.h>
#include "../err.h"
#include "../measured_strings.h"
#include "../messages.h"
#include "../modules.h"
-#include "../netif/netif_device_id_type.h"
+#include "../packet.h"
+#include "../include/sockaddr.h"
+#include "../include/socket.h"
+#include "../netif/device.h"
+
#include "ip.h"
+#include "ip_messages.h"
+#include "ip_module.h"
-#define DEFAULT_IPV 4
+#define DEFAULT_IPV 4
+#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
+#define IPC_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call )
+#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG2( * 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 )
-int parse_address( char * value, address_ref address );
+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 );
+
/** Initializes the module.
*/
int ip_initialize( void ){
ip_netifs_initialize( & ip_globals.netifs );
+ ip_protos_initialize( & ip_globals.protos );
return EOK;
}
-int ip_call( ipc_callid_t callid ){
+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 parse_address( char * value, address_ref address ){
- char * next;
- int index;
-
- if( ! value ){
- ( * address )[ 0 ] = ( * address )[ 1 ] = ( * address )[ 2 ] = ( * address )[ 3 ] = 0;
- return ENOENT;
- }
- next = value;
- for( index = 0; index < 4; ++ index ){
- if(( ! next ) || ( ! * next )) return EINVAL;
- if( index ) ++ next;
- ( * address )[ index ] = strtoul( next, & next, 0 );
- }
- return EOK;
-}
-
-int ip_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
+int ip_device_message( device_id_t device_id, services_t service ){
ERROR_DECLARE;
ip_netif_ref ip_netif;
@@ -95,85 +101,176 @@
measured_string_ref settings;
char * data;
- switch( method ){
+ ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t ));
+ if( ! ip_netif ) return ENOMEM;
+ ip_netif->device_id = device_id;
+ // get configuration
+ // TODO mapping
+ message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer );
+ // send names and get settings
+ if( ERROR_OCCURED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
+ || ERROR_OCCURED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
+ async_wait_for( message, NULL );
+ 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 = ! strcmp( settings[ 1 ].value, "DHCP" );
+ if( ip_netif->dhcp ){
+ // TODO dhcp
+ free( ip_netif );
+ return ENOTSUP;
+ }else if( ip_netif->ipv == 4 ){
+ if( ERROR_OCCURED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
+ || ERROR_OCCURED( 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( ip_netif );
+ return EINVAL;
+ }
+ }else{
+ // TODO ipv6
+ free( ip_netif );
+ return ENOTSUP;
+ }
+ // TODO ARP module
+ }
+ // TODO arp module
+ free( settings );
+ free( data );
+ // end request
+ // TODO mapping
+ async_wait_for( message, NULL );
+ // print the settings
+ printf( "\n -IPV =\t%d", ip_netif->ipv );
+ printf( "\n -configuration =\t%s", ip_netif->dhcp ? "dhcp" : "static" );
+ // TODO ipv6
+ data = malloc( INET_ADDRSTRLEN );
+ if( data ){
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->address, data, INET_ADDRSTRLEN );
+ printf( "\n -address =\t%s", data );
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN );
+ printf( "\n -netmask =\t%s", data );
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN );
+ printf( "\n -gateway =\t%s", data );
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN );
+ printf( "\n -broadcast =\t%s", data );
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
+ printf( "\n -dns1 =\t%s", data );
+ inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
+ printf( "\n -dns2 =\t%s", data );
+ free( data );
+ }
+ // TODO mapping
+ ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
+ if( ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
+ free( ip_netif );
+ return ERROR_CODE;
+ }
+ return EOK;
+}
+
+void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall ){
+ ERROR_DECLARE;
+
+ ipc_callid_t callid;
+ ipc_call_t call;
+// ipc_call_t answer;
+// int count;
+ int result;
+ packet_t packet;
+
+ /*
+ * Accept the connection
+ * - Answer the first IPC_M_CONNECT_ME_TO call.
+ */
+ ipc_answer_0( iid, EOK );
+
+ while( true ){
+/* // refresh data
+ count = 0;
+ IPC_SET_RETVAL( answer, 0 );
+ // just to be precize
+ IPC_SET_RETVAL( answer, 0 );
+ IPC_SET_ARG1( answer, 0 );
+ IPC_SET_ARG2( answer, 0 );
+ IPC_SET_ARG3( answer, 0 );
+ IPC_SET_ARG4( answer, 0 );
+ IPC_SET_ARG5( answer, 0 );
+*/
+ callid = async_get_call( & call );
+ switch( IPC_GET_METHOD( call )){
+ case NET_IL_DEVICE_STATE:
+ case NET_NIL_DEVICE_STATE:
+ result = ip_state_message( IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
+ ipc_answer_0( callid, result );
+ // TODO packer received
+ case NET_IL_RECEIVED:
+ case NET_NIL_RECEIVED:
+ if( ERROR_OCCURED( result = packet_receive( & packet ))){
+ ipc_answer_0( callid, ERROR_CODE );
+ continue;
+ }
+ //result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
+ packet_destroy( packet );
+ ipc_answer_0( callid, result );
+ }
+ }
+}
+
+int ip_state_message( device_id_t device_id, device_state_t state ){
+ // TODO state
+ printf( "\nip - device %d changed state to %d\n", device_id, state );
+ return EOK;
+}
+
+int ip_register_message( int protocol, int phone ){
+ ERROR_DECLARE;
+
+ ip_proto_ref proto;
+
+ proto = ( ip_proto_ref ) malloc( sizeof( ip_protos_t ));
+ if( ! proto ) return ENOMEM;
+ proto->protocol = protocol;
+ proto->phone = phone;
+ if( ERROR_OCCURED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){
+ free( proto );
+ return ERROR_CODE;
+ }
+ return EOK;
+}
+
+int ip_send_message( device_id_t device_id, packet_t packet ){
+ // TODO send packet
+ printf( "Packet to send via %d: %s", device_id, packet_get_data( packet ));
+ return EOK;
+}
+
+int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+ ERROR_DECLARE;
+
+ packet_t packet;
+
+ * answer_count = 0;
+ switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_IP_ECHO:
- if( result1 ) * result1 = arg1;
- if( result2 ) * result2 = arg2;
- if( result3 ) * result3 = arg3;
- return EOK;
+ * 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:
- ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t ));
- if( ! ip_netif ) return ENOMEM;
- ip_netif->device_id = arg1;
- // get configuration
- message = async_send_2( ip_globals.networking_phone, NET_NETWORKING_GET_DEVICE_CONFIGURATION, ip_netif->device_id, count, & answer );
- // send names and get settings
- if( ERROR_OCCURED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
- || ERROR_OCCURED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
- async_wait_for( message, NULL );
- 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 = ! strcmp( settings[ 1 ].value, "DHCP" );
- if( ip_netif->dhcp ){
- // TODO dhcp
- free( ip_netif );
- return ENOTSUP;
- }else if( ip_netif->ipv == 4 ){
- if( ERROR_OCCURED( parse_address( settings[ 2 ].value, & ip_netif->address ))
- || ERROR_OCCURED( parse_address( settings[ 3 ].value, & ip_netif->netmask ))
- || ( parse_address( settings[ 4 ].value, & ip_netif->gateway ) == EINVAL )
- || ( parse_address( settings[ 5 ].value, & ip_netif->broadcast ) == EINVAL )
- || ( parse_address( settings[ 6 ].value, & ip_netif->dns1 ) == EINVAL )
- || ( parse_address( settings[ 7 ].value, & ip_netif->dns2 ) == EINVAL )){
- free( ip_netif );
- return EINVAL;
- }
- }else{
- // TODO ipv6
- free( ip_netif );
- return ENOTSUP;
- }
- // TODO ARP module
- }
- // print the settings
- printf( "\n -IPV=%d", ip_netif->ipv );
- printf( "\n -configuration=%s", ip_netif->dhcp ? "dhcp" : "static" );
- // TODO ipv6
- printf( "\n -address=%d.%d.%d.%d", ip_netif->address[ 0 ], ip_netif->address[ 1 ], ip_netif->address[ 2 ], ip_netif->address[ 3 ] );
- printf( "\n -netmask=%d.%d.%d.%d", ip_netif->netmask[ 0 ], ip_netif->netmask[ 1 ], ip_netif->netmask[ 2 ], ip_netif->netmask[ 3 ] );
- printf( "\n -gateway=%d.%d.%d.%d", ip_netif->gateway[ 0 ], ip_netif->gateway[ 1 ], ip_netif->gateway[ 2 ], ip_netif->gateway[ 3 ] );
- printf( "\n -broadcast=%d.%d.%d.%d", ip_netif->broadcast[ 0 ], ip_netif->broadcast[ 1 ], ip_netif->broadcast[ 2 ], ip_netif->broadcast[ 3 ] );
- printf( "\n -dns1=%d.%d.%d.%d", ip_netif->dns1[ 0 ], ip_netif->dns1[ 1 ], ip_netif->dns1[ 2 ], ip_netif->dns1[ 3 ] );
- printf( "\n -dns2=%d.%d.%d.%d", ip_netif->dns2[ 0 ], ip_netif->dns2[ 1 ], ip_netif->dns2[ 2 ], ip_netif->dns2[ 3 ] );
- // TODO arp module
- free( settings );
- free( data );
- // end request
- async_wait_for( message, NULL );
- ip_netif->phone = connect_to_service( arg2 );
- if( ERROR_OCCURED( async_req_2_0( ip_netif->phone, NET_LL_REGISTER, arg1, SERVICE_IP ))
- || ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
- free( ip_netif );
- return ERROR_CODE;
- }
- return EOK;
- case NET_IL_DEVICE_STATE_CHANGED:
- case NET_LL_DEVICE_STATE_CHANGED:
- // arg1 device id
- // arg2 state
- // TODO state
- printf( "\nip - device %d changed state to %d\n", arg1, arg2 );
- case NET_IP_TCP_REGISTER:
- ip_globals.tcp_phone = connect_to_service( arg1 );
- return EOK;
+ return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
+ case IPC_M_CONNECT_TO_ME:
+ return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call ));
+ case NET_IP_SEND:
+ ERROR_PROPAGATE( packet_receive( & packet ));
+ return ip_send_message( IPC_GET_DEVICE( call ), packet );
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/ip/Makefile
46,9 → 46,11
$(NAME).c \
../measured_strings.c \
../module.c \
../modules.c
../modules.c \
../packet.c \
../sockaddr.c
 
DEFS += -D NETWORKING_$(NETWORKING) -D $(NAME)_call=module_call -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
DEFS += -D IP_BUNDLE=1 -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
/branches/network/uspace/srv/net/ip/ip.h
34,49 → 34,51
* @file
*/
 
#ifndef __NET_IP_INTERNALS_H__
#define __NET_IP_INTERNALS_H__
#ifndef __NET_IP_H__
#define __NET_IP_H__
 
#include <ipc/ipc.h>
 
#include "../netif/netif_device_id_type.h"
#include "../include/sockaddr.h"
#include "../netif/device.h"
 
#define IP_MAX_ADDRESS_LENGTH 4
 
typedef int address_t[ IP_MAX_ADDRESS_LENGTH ];
typedef address_t * address_ref;
 
typedef struct ip_netif ip_netif_t;
typedef ip_netif_t * ip_netif_ref;
 
typedef struct ip_proto ip_proto_t;
typedef ip_proto_t * ip_proto_ref;
 
typedef struct ip_globals ip_globals_t;
 
DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t )
 
INT_MAP_DECLARE( ip_protos, ip_proto_t )
 
struct ip_netif{
netif_device_id_t device_id;
device_id_t device_id;
int phone;
int ipv;
int dhcp;
address_t address;
address_t netmask;
address_t gateway;
address_t broadcast;
address_t dns1;
address_t dns2;
in_addr_t address;
in_addr_t netmask;
in_addr_t gateway;
in_addr_t broadcast;
in_addr_t dns1;
in_addr_t dns2;
// TODO modules
};
 
struct ip_proto{
int protocol;
int phone;
};
 
struct ip_globals{
int networking_phone;
int tcp_phone;
ip_netifs_t netifs;
ip_protos_t protos;
};
 
int ip_initialize( void );
int ip_call( ipc_callid_t callid );
int ip_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/ip/ip_module.c
35,17 → 35,20
 
#include <async.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../err.h"
#include "../modules.h"
 
#include "ip.h"
#include "ip_module.h"
 
#define NAME "IP protocol"
 
void ip_print_name( void );
int ip_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
int ip_start_module( async_client_conn_t client_connection );
 
extern ip_globals_t ip_globals;
 
53,15 → 56,19
printf( NAME );
}
 
int ip_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){
services_t need[ 2 ];
int * need_phone[ 2 ];
int ip_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
need[ 0 ] = SERVICE_NETWORKING;
need[ 1 ] = NULL;
need_phone[ 0 ] = & ip_globals.networking_phone;
need_phone[ 1 ] = NULL;
return start_service( SERVICE_IP, need, need_phone, client_connection, ip_initialize );
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
ip_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
ERROR_PROPAGATE( ip_initialize());
ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash ));
 
async_manager();
 
return EOK;
}
 
/** @}
/branches/network/uspace/srv/net/networking_startup/networking_startup.c
36,6 → 36,7
#include <async.h>
#include <stdio.h>
#include <task.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
64,7 → 65,7
}
// start networking
networking_phone = connect_to_service( SERVICE_NETWORKING );
if( ERROR_OCCURED( ipc_call_sync_0_0( networking_phone, NET_NETWORKING_STARTUP ))){
if( ERROR_OCCURED( ipc_call_sync_0_0( networking_phone, NET_NET_STARTUP ))){
printf( "\n" NAME " - ERROR %d\n", ERROR_CODE );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/sockaddr.c
0,0 → 1,112
/*
* Copyright (c) 2008 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/** @file
*
*/
 
#include <stdio.h>
#include <string.h>
 
#include "include/sockaddr.h"
#include "include/socket.h"
 
#include "err.h"
 
int inet_pton( uint16_t family, const char * address, uint8_t * data ){
const char * next;
char * last;
int index;
int count;
int base;
size_t bytes;
size_t shift;
unsigned long value;
 
if( ! data ) return EINVAL;
switch( family ){
case AF_INET:
count = 4;
base = 10;
bytes = 1;
break;
case AF_INET6:
count = 16;
base = 16;
bytes = 4;
break;
default:
return ENOTSUP;
}
if( ! address ){
memset( data, 0, count );
return ENOENT;
}
next = address;
index = 0;
do{
if( next && ( * next )){
if( index ) ++ next;
value = strtoul( next, & last, base );
next = last;
shift = bytes - 1;
do{
// like little endian
data[ index + shift ] = value;
// data[ index ] = value;
value >>= 8;
// ++ index;
}while( shift -- );
index += bytes;
}else{
memset( data + index, 0, count - index );
return EOK;
}
}while( index < count );
return EOK;
}
 
int inet_ntop( uint16_t family, const uint8_t * data, char * address, size_t length ){
if(( ! data ) || ( ! address )) return EINVAL;
switch( family ){
case AF_INET: if( length < INET_ADDRSTRLEN ) return ENOMEM;
sprintf( address, "%hhu.%hhu.%hhu.%hhu", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] );
return EOK;
case AF_INET6: if( length < INET6_ADDRSTRLEN ) return ENOMEM;
sprintf( address, "%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx", 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 ] );
return EOK;
default: return ENOTSUP;
}
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: network/uspace/srv/net/int_map.h
===================================================================
--- network/uspace/srv/net/int_map.h (revision 3845)
+++ network/uspace/srv/net/int_map.h (revision 3846)
@@ -41,148 +41,165 @@
#include <malloc.h>
#include <string.h>
-#define INT_MAP_MAGIC_VALUE 0x11223344
+#define INT_MAP_MAGIC_VALUE 0x11223344
#define INT_MAP_ITEM_MAGIC_VALUE 0x55667788
-#define INT_MAP_DECLARE( name, type ) \
- \
-typedef struct name name##_t; \
-typedef name##_t * name##_ref; \
-typedef struct name##_item name##_item_t; \
-typedef name##_item_t * name##_item_ref; \
- \
-struct name##_item{ \
- int key; \
- type * value; \
- int magic; \
-}; \
- \
-struct name{ \
- int size; \
- int next; \
- name##_item_ref items; \
- int magic; \
-}; \
- \
-int name##_add( name##_ref map, int key, type * value ); \
-int name##_count( name##_ref map ); \
-void name##_destroy( name##_ref map ); \
-void name##_exclude( name##_ref map, int key ); \
-void name##_exclude_index( name##_ref map, int index ); \
-type * name##_find( name##_ref map, int key ); \
-type * name##_get_index( name##_ref map, int index ); \
-int name##_initialize( name##_ref map ); \
-int name##_is_valid( name##_ref map ); \
-void name##_item_destroy( name##_item_ref item ); \
-int name##_item_is_valid( name##_item_ref item );
+#define INT_MAP_DECLARE( name, type ) \
+ \
+typedef struct name name##_t; \
+typedef name##_t * name##_ref; \
+typedef struct name##_item name##_item_t; \
+typedef name##_item_t * name##_item_ref; \
+ \
+struct name##_item{ \
+ int key; \
+ type * value; \
+ int magic; \
+}; \
+ \
+struct name{ \
+ int size; \
+ int next; \
+ name##_item_ref items; \
+ int magic; \
+}; \
+ \
+int name##_add( name##_ref map, int key, type * value ); \
+void name##_clear( name##_ref map ); \
+int name##_count( name##_ref map ); \
+void name##_destroy( name##_ref map ); \
+void name##_exclude( name##_ref map, int key ); \
+void name##_exclude_index( name##_ref map, int index ); \
+type * name##_find( name##_ref map, int key ); \
+type * name##_get_index( name##_ref map, int index ); \
+int name##_initialize( name##_ref map ); \
+int name##_is_valid( name##_ref map ); \
+void name##_item_destroy( name##_item_ref item ); \
+int name##_item_is_valid( name##_item_ref item );
-#define INT_MAP_IMPLEMENT( name, type ) \
- \
-int name##_add( name##_ref map, int key, type * value ){ \
- if( name##_is_valid( map )){ \
- if( map->next == ( map->size - 1 )){ \
- name##_item_ref tmp; \
- \
+#define INT_MAP_IMPLEMENT( name, type ) \
+ \
+int name##_add( name##_ref map, int key, type * value ){ \
+ if( name##_is_valid( map )){ \
+ if( map->next == ( map->size - 1 )){ \
+ name##_item_ref tmp; \
+ \
tmp = ( name##_item_ref ) malloc( sizeof( name##_item_t ) * 2 * map->size ); \
- if( ! tmp ) return ENOMEM; \
- map->size *= 2; \
- memcpy( tmp, map->items, sizeof( name##_item_t ) * map->next ); \
- free( map->items ); \
- map->items = tmp; \
- } \
- map->items[ map->next ].key = key; \
- map->items[ map->next ].value = value; \
- map->items[ map->next ].magic = INT_MAP_ITEM_MAGIC_VALUE; \
- ++ map->next; \
- map->items[ map->next ].magic = 0; \
- return map->next - 1; \
- } \
- return EINVAL; \
-} \
- \
-int name##_count( name##_ref map ){ \
- return name##_is_valid( map ) ? map->next : -1; \
-} \
- \
-void name##_destroy( name##_ref map ){ \
- if( name##_is_valid( map )){ \
- int index; \
- \
- map->magic = 0; \
- for( index = 0; index < map->next; ++ index ){ \
- if( name##_item_is_valid( &( map->items[ index ] ))){ \
- name##_item_destroy( &( map->items[ index ] )); \
- } \
- } \
- free( map->items ); \
- } \
-} \
- \
-void name##_exclude( name##_ref map, int key ){ \
- if( name##_is_valid( map )){ \
- int index; \
- \
- for( index = 0; index < map->next; ++ index ){ \
+ if( ! tmp ) return ENOMEM; \
+ map->size *= 2; \
+ memcpy( tmp, map->items, sizeof( name##_item_t ) * map->next ); \
+ free( map->items ); \
+ map->items = tmp; \
+ } \
+ map->items[ map->next ].key = key; \
+ map->items[ map->next ].value = value; \
+ map->items[ map->next ].magic = INT_MAP_ITEM_MAGIC_VALUE; \
+ ++ map->next; \
+ map->items[ map->next ].magic = 0; \
+ return map->next - 1; \
+ } \
+ return EINVAL; \
+} \
+ \
+void name##_clear( name##_ref map ){ \
+ if( name##_is_valid( map )){ \
+ int index; \
+ \
+/* map->magic = 0;*/ \
+ for( index = 0; index < map->next; ++ index ){ \
+ if( name##_item_is_valid( &( map->items[ index ] ))){ \
+ name##_item_destroy( &( map->items[ index ] )); \
+ } \
+ } \
+ map->next = 0; \
+ map->items[ map->next ].magic = 0; \
+/* map->magic = INT_MAP_MAGIC_VALUE;*/ \
+ } \
+} \
+ \
+int name##_count( name##_ref map ){ \
+ return name##_is_valid( map ) ? map->next : -1; \
+} \
+ \
+void name##_destroy( name##_ref map ){ \
+ if( name##_is_valid( map )){ \
+ int index; \
+ \
+ map->magic = 0; \
+ for( index = 0; index < map->next; ++ index ){ \
+ if( name##_item_is_valid( &( map->items[ index ] ))){ \
+ name##_item_destroy( &( map->items[ index ] )); \
+ } \
+ } \
+ free( map->items ); \
+ } \
+} \
+ \
+void name##_exclude( name##_ref map, int key ){ \
+ if( name##_is_valid( map )){ \
+ int index; \
+ \
+ for( index = 0; index < map->next; ++ index ){ \
if( name##_item_is_valid( &( map->items[ index ] )) && ( map->items[ index ].key == key )){ \
- name##_item_destroy( &( map->items[ index ] )); \
- } \
- } \
- } \
-} \
- \
-void name##_exclude_index( name##_ref map, int index ){ \
+ name##_item_destroy( &( map->items[ index ] )); \
+ } \
+ } \
+ } \
+} \
+ \
+void name##_exclude_index( name##_ref map, int index ){ \
if( name##_is_valid( map ) && ( index >= 0 ) && ( index < map->next ) && name##_item_is_valid( &( map->items[ index ] ))){ \
- name##_item_destroy( &( map->items[ index ] )); \
- } \
-} \
- \
-type * name##_find( name##_ref map, int key ){ \
- if( name##_is_valid( map )){ \
- int index; \
- \
- for( index = 0; index < map->next; ++ index ){ \
+ name##_item_destroy( &( map->items[ index ] )); \
+ } \
+} \
+ \
+type * name##_find( name##_ref map, int key ){ \
+ if( name##_is_valid( map )){ \
+ int index; \
+ \
+ for( index = 0; index < map->next; ++ index ){ \
if( name##_item_is_valid( &( map->items[ index ] )) && ( map->items[ index ].key == key )){ \
- return map->items[ index ].value; \
- } \
- } \
- } \
- return NULL; \
-} \
- \
-type * name##_get_index( name##_ref map, int index ){ \
+ return map->items[ index ].value; \
+ } \
+ } \
+ } \
+ return NULL; \
+} \
+ \
+type * name##_get_index( name##_ref map, int index ){ \
if( name##_is_valid( map ) && ( index >= 0 ) && ( index < map->next ) && name##_item_is_valid( &( map->items[ index ] ))){ \
- return map->items[ index ].value; \
- } \
- return NULL; \
-} \
- \
-int name##_initialize( name##_ref map ){ \
- if( ! map ) return EINVAL; \
- map->size = 2; \
- map->next = 0; \
+ return map->items[ index ].value; \
+ } \
+ return NULL; \
+} \
+ \
+int name##_initialize( name##_ref map ){ \
+ if( ! map ) return EINVAL; \
+ map->size = 2; \
+ map->next = 0; \
map->items = ( name##_item_ref ) malloc( sizeof( name##_item_t ) * map->size ); \
- if( ! map->items ) return ENOMEM; \
- map->items[ map->next ].magic = 0; \
- map->magic = INT_MAP_MAGIC_VALUE; \
- return EOK; \
-} \
- \
-int name##_is_valid( name##_ref map ){ \
- return map && ( map->magic == INT_MAP_MAGIC_VALUE ); \
-} \
- \
-void name##_item_destroy( name##_item_ref item ){ \
- if( name##_item_is_valid( item )){ \
- item->magic = 0; \
- if( item->value ){ \
- free( item->value ); \
- item->value = NULL; \
- } \
- } \
-} \
- \
-int name##_item_is_valid( name##_item_ref item ){ \
- return item && ( item->magic == INT_MAP_ITEM_MAGIC_VALUE ); \
+ if( ! map->items ) return ENOMEM; \
+ map->items[ map->next ].magic = 0; \
+ map->magic = INT_MAP_MAGIC_VALUE; \
+ return EOK; \
+} \
+ \
+int name##_is_valid( name##_ref map ){ \
+ return map && ( map->magic == INT_MAP_MAGIC_VALUE ); \
+} \
+ \
+void name##_item_destroy( name##_item_ref item ){ \
+ if( name##_item_is_valid( item )){ \
+ item->magic = 0; \
+ if( item->value ){ \
+ free( item->value ); \
+ item->value = NULL; \
+ } \
+ } \
+} \
+ \
+int name##_item_is_valid( name##_item_ref item ){ \
+ return item && ( item->magic == INT_MAP_ITEM_MAGIC_VALUE ); \
}
#endif