0,0 → 1,153 |
/* |
* 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 <async.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 "netif.h" |
#include "netif_device_id_type.h" |
|
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 ); |
|
DEVICE_MAP_IMPLEMENT( netif_device_map, netif_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 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 ); |
if( ! * device ) return ENOENT; |
if(( ** device ).status == 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; |
stats->tx_packets = 0; |
stats->rx_bytes = 0; |
stats->tx_bytes = 0; |
stats->rx_errors = 0; |
stats->tx_errors = 0; |
stats->rx_dropped = 0; |
stats->tx_dropped = 0; |
stats->multicast = 0; |
stats->collisions = 0; |
stats->rx_length_errors = 0; |
stats->rx_over_errors = 0; |
stats->rx_crc_errors = 0; |
stats->rx_frame_errors = 0; |
stats->rx_fifo_errors = 0; |
stats->rx_missed_errors = 0; |
stats->tx_aborted_errors = 0; |
stats->tx_carrier_errors = 0; |
stats->tx_fifo_errors = 0; |
stats->tx_heartbeat_errors = 0; |
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 ){ |
ERROR_DECLARE; |
|
size_t length; |
netif_device_ref device; |
|
// printf( "\nNETIF message %d", method ); |
switch( method ){ |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NETIF_PROBE_AUTO: |
return netif_probe_auto_message( arg1, arg2, arg3, result1, result2, result3 ); |
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 )); |
// TODO back phone |
device->ll_registered = callid; |
return EOK; |
case NET_NETIF_SEND: |
return netif_send_message( arg1, arg2, arg3, result1, result2, result3 ); |
case NET_NETIF_START: |
return netif_start_message( arg1, arg2, arg3, result1, result2, result3 ); |
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 )); |
case NET_NETIF_STOP: |
return netif_stop_message( arg1, arg2, arg3, result1, result2, result3 ); |
} |
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 ]; |
|
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*/ NULL, NULL, client_connection, netif_initialize ); |
} |
|
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |