/branches/network/uspace/srv/net/il/arp/arp_wrappers.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/il/arp/arp_messages.h |
---|
0,0 → 1,61 |
/* |
* Copyright (c) 2009 Lukas Mejdrech |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arp |
* @{ |
*/ |
/** @file |
*/ |
#ifndef __NET_ARP_MESSAGES__ |
#define __NET_ARP_MESSAGES__ |
#include <ipc/ipc.h> |
#include "../../messages.h" |
typedef enum{ |
/* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */ |
NET_ARP_DEVICE = NET_ARP_FIRST, |
/* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */ |
NET_ARP_TRANSLATE, |
/* ( device_id ) */ |
NET_ARP_CLEAR_DEVICE, |
/* () */ |
NET_ARP_CLEAN_CACHE, |
} arp_messages; |
/** Returns the protocol service message parameter. |
*/ |
#define ARP_GET_NETIF( call ) ( services_t ) IPC_GET_ARG2( * call ) |
#endif |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/il/arp/arp.c |
---|
40,6 → 40,7 |
#include <mem.h> |
#include <rwlock.h> |
#include <stdio.h> |
#include <task.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
50,8 → 51,8 |
#include "../../include/byteorder.h" |
#include "../../include/device.h" |
#include "../../include/arp_messages.h" |
#include "../../include/nil_messages.h" |
#include "../../include/arp_interface.h" |
#include "../../include/nil_interface.h" |
#include "../../include/protocol_map.h" |
#include "../../structures/measured_strings.h" |
58,16 → 59,33 |
#include "../../structures/packet/packet.h" |
#include "../../structures/packet/packet_client.h" |
#include "../il_messages.h" |
#include "arp.h" |
#include "arp_header.h" |
#include "arp_oc.h" |
#include "arp_module.h" |
#include "arp_wrappers.h" |
#include "arp_messages.h" |
/** ARP global data. |
*/ |
arp_globals_t arp_globals; |
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ); |
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ); |
/** Clears the whole cache. |
* @returns EOK on success. |
*/ |
int arp_clean_cache_req( int arp_phone ); |
/** Clears the device specific data from the cache. |
* @param device_id The device identifier. Input parameter. |
* @returns EOK on success. |
* @returns ENOENT if the device is not found in the cache. |
*/ |
int arp_clear_device_req( int arp_phone, device_id_t device_id ); |
/** Creates new protocol specific data. |
* @param proto Protocol specific data. Output parameter. |
* @param service Protocol module service. Input parameter. |
134,7 → 152,11 |
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t ) |
int arp_clear_device_wrapper( device_id_t device_id ){ |
int arp_task_get_id( void ){ |
return task_get_id(); |
} |
int arp_clear_device_req( int arp_phone, device_id_t device_id ){ |
arp_device_ref device; |
rwlock_write_lock( & arp_globals.lock ); |
144,12 → 166,12 |
return ENOENT; |
} |
clear_device( device ); |
printf( "\nDevice %d cleared", device_id ); |
printf( "Device %d cleared\n", device_id ); |
rwlock_write_unlock( & arp_globals.lock ); |
return EOK; |
} |
int arp_clean_cache_wrapper( void ){ |
int arp_clean_cache_req( int arp_phone ){ |
int count; |
arp_device_ref device; |
164,11 → 186,11 |
} |
arp_cache_clear( & arp_globals.cache ); |
rwlock_write_unlock( & arp_globals.lock ); |
printf( "\nCache cleaned" ); |
printf( "Cache cleaned\n" ); |
return EOK; |
} |
int arp_device_wrapper( device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){ |
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){ |
ERROR_DECLARE; |
measured_string_ref tmp; |
181,7 → 203,7 |
return ERROR_CODE; |
} |
int arp_translate_wrapper( device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){ |
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){ |
measured_string_ref tmp; |
rwlock_read_lock( & arp_globals.lock ); |
238,7 → 260,7 |
device = arp_cache_find( & arp_globals.cache, device_id ); |
if( device ){ |
if( device->service != service ){ |
printf( "\nDevice %d already exists", device->device_id ); |
printf( "Device %d already exists\n", device->device_id ); |
rwlock_write_unlock( & arp_globals.lock ); |
return EEXIST; |
} |
260,7 → 282,7 |
return index; |
} |
} |
printf( "\nCache of the existing device %d cleaned", device->device_id ); |
printf( "Cache of the existing device %d cleaned\n", device->device_id ); |
}else{ |
index = hardware_map( service ); |
if( ! index ) return ENOENT; |
327,7 → 349,7 |
free( device ); |
return ERROR_CODE; |
} |
printf( "\nNew device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d", device->device_id, device->hardware, device->service ); |
printf( "New device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d\n", device->device_id, device->hardware, device->service ); |
} |
rwlock_write_unlock( & arp_globals.lock ); |
return EOK; |
351,7 → 373,7 |
// ARP packet content size = header + ( address + translation ) * 2 |
length = 8 + ( CONVERT_SIZE( char, uint8_t, proto->addr->length ) + CONVERT_SIZE( char, uint8_t, device->addr->length )) * 2; |
if( length > device->content ) return NULL; |
packet = packet_get_4( arp_globals.networking_phone, device->addr_len, device->prefix, length, device->suffix ); |
packet = packet_get_4( arp_globals.net_phone, device->addr_len, device->prefix, length, device->suffix ); |
if( ! packet ) return NULL; |
header = ( arp_header_ref ) packet_suffix( packet, length ); |
header->hardware = htons( device->hardware ); |
428,7 → 450,7 |
packet_set_addr( packet, src_hw, des_hw, header->hardware_length ); |
nil_send_msg( device->phone, device_id, packet, SERVICE_ARP ); |
}else{ |
pq_release( arp_globals.networking_phone, packet_get_id( packet )); |
pq_release( arp_globals.net_phone, packet_get_id( packet )); |
} |
} |
return EOK; |
449,6 → 471,10 |
arp_protos_clear( & device->protos ); |
} |
int arp_connect_module( services_t service ){ |
return EOK; |
} |
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
ERROR_DECLARE; |
456,7 → 482,7 |
measured_string_ref translation; |
char * data; |
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_ARP_FIRST ); |
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST ); |
* answer_count = 0; |
switch( IPC_GET_METHOD( * call )){ |
case IPC_M_PHONE_HUNGUP: |
463,7 → 489,7 |
return EOK; |
case NET_ARP_DEVICE: |
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 )); |
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), ARP_GET_PROTO( call ), address ))){ |
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), ARP_GET_NETIF( call ), address ))){ |
free( address ); |
free( data ); |
} |
471,7 → 497,7 |
case NET_ARP_TRANSLATE: |
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 )); |
rwlock_read_lock( & arp_globals.lock ); |
translation = arp_translate_message( IPC_GET_DEVICE( call ), ARP_GET_PROTO( call ), address ); |
translation = arp_translate_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), address ); |
free( address ); |
free( data ); |
if( ! translation ){ |
482,9 → 508,9 |
rwlock_read_unlock( & arp_globals.lock ); |
return ERROR_CODE; |
case NET_ARP_CLEAR_DEVICE: |
return arp_clear_device_wrapper( IPC_GET_DEVICE( call )); |
return arp_clear_device_req( 0, IPC_GET_DEVICE( call )); |
case NET_ARP_CLEAN_CACHE: |
return arp_clean_cache_wrapper(); |
return arp_clean_cache_req( 0 ); |
} |
return ENOTSUP; |
} |
501,7 → 527,7 |
ipc_answer_0( iid, EOK ); |
break; |
case NET_IL_RECEIVED: |
if( ! ERROR_OCCURRED( packet_translate( arp_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){ |
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){ |
rwlock_read_lock( & arp_globals.lock ); |
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( icall ), packet ); |
rwlock_read_unlock( & arp_globals.lock ); |
/branches/network/uspace/srv/net/il/arp/arp.h |
---|
160,7 → 160,7 |
struct arp_globals{ |
/** Networking module phone. |
*/ |
int networking_phone; |
int net_phone; |
/** Safety lock. |
*/ |
rwlock_t lock; |
/branches/network/uspace/srv/net/il/arp/arp_module.c |
---|
46,6 → 46,8 |
#include "../../err.h" |
#include "../../modules.h" |
#include "../../include/net_interface.h" |
#include "../../structures/packet/packet.h" |
#include "arp.h" |
58,7 → 60,7 |
/** Prints the module name. |
* @see NAME |
*/ |
void arp_print_name( void ); |
void module_print_name( void ); |
/** Starts the ARP module. |
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop. |
67,23 → 69,24 |
* @returns Other error codes as defined for the arp_initialize() function. |
* @returns Other error codes as defined for the REGISTER_ME() macro function. |
*/ |
int arp_start_module( async_client_conn_t client_connection ); |
int module_start( async_client_conn_t client_connection ); |
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
/** ARP module global data. |
*/ |
extern arp_globals_t arp_globals; |
void arp_print_name( void ){ |
void module_print_name( void ){ |
printf( "%s", NAME ); |
} |
int arp_start_module( async_client_conn_t client_connection ){ |
int module_start( async_client_conn_t client_connection ){ |
ERROR_DECLARE; |
ipcarg_t phonehash; |
async_set_client_connection( client_connection ); |
arp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING ); |
arp_globals.net_phone = net_connect_module( SERVICE_NETWORKING ); |
ERROR_PROPAGATE( pm_init()); |
if( ERROR_OCCURRED( arp_initialize()) |
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ARP, & phonehash ))){ |
97,5 → 100,9 |
return EOK; |
} |
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
return arp_message( callid, call, answer, answer_count ); |
} |
/** @} |
*/ |
/branches/network/uspace/srv/net/il/arp/Makefile |
---|
43,8 → 43,9 |
$(STRUCTURES)char_map.c \ |
$(STRUCTURES)measured_strings.c \ |
$(STRUCTURES)packet/packet.c \ |
$(STRUCTURES)packet/packet_client.c |
$(STRUCTURES)/packet/packet_client.c \ |
$(STRUCTURES)/packet/packet_remote.c \ |
$(NET_BASE)nil/nil_remote.c \ |
$(NET_BASE)net/net_remote.c |
NET_DEFS += -D ARP_BUNDLE=1 |
include $(NET_BASE)Makefile.module |
/branches/network/uspace/srv/net/il/arp/arp_remote.c |
---|
0,0 → 1,83 |
/* |
* Copyright (c) 2009 Lukas Mejdrech |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arp |
* @{ |
*/ |
/** @file |
*/ |
#include <async.h> |
#include <errno.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include "../../messages.h" |
#include "../../modules.h" |
#include "../../include/device.h" |
#include "../../include/arp_interface.h" |
#include "../../structures/measured_strings.h" |
#include "arp_messages.h" |
int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){ |
aid_t message_id; |
ipcarg_t result; |
message_id = async_send_3( arp_phone, NET_ARP_DEVICE, device_id, protocol, netif, NULL ); |
measured_strings_send( arp_phone, address, 1 ); |
async_wait_for( message_id, & result ); |
return result; |
} |
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data ){ |
return generic_translate_req( arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data ); |
} |
int arp_clear_device_req( int arp_phone, device_id_t device_id ){ |
return async_req_1_0( arp_phone, NET_ARP_CLEAR_DEVICE, device_id ); |
} |
int arp_clean_cache_req( int arp_phone ){ |
return async_req_0_0( arp_phone, NET_ARP_CLEAN_CACHE ); |
} |
int arp_connect_module( services_t service ){ |
return connect_to_service( SERVICE_ARP ); |
} |
int arp_task_get_id( void ){ |
return 0; |
} |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |