/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 |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp.c |
---|
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 ); |
} |
} |
} |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp.h |
---|
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 |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_module.c |
---|
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; |
} |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_oc.h |
---|
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 |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/Makefile |
---|
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 $@ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_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 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 |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |