Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4742 → Rev 4743

/branches/network/uspace/srv/net/nil/eth/eth.c
49,7 → 49,7
#include "../../modules.h"
 
#include "../../include/byteorder.h"
#include "../../include/crc.h"
#include "../../include/checksum.h"
#include "../../include/ethernet_lsap.h"
#include "../../include/ethernet_protocols.h"
#include "../../include/protocol_map.h"
191,7 → 191,7
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the net_get_device_conf_req() function.
* @returns Other error codes as defined for the netif_bind_service() function.
* @returns Other error codes as defined for the netif_get_addr() function.
* @returns Other error codes as defined for the netif_get_addr_req() function.
*/
int eth_device_message( device_id_t device_id, services_t service, size_t mtu );
 
363,9 → 363,7
if( ! str_lcmp( configuration[ 0 ].value, "DIX", configuration[ 0 ].length )){
device->flags |= ETH_DIX;
}else if( ! str_lcmp( configuration[ 0 ].value, "8023_2_LSAP", configuration[ 0 ].length )){
// TODO 8023_2_LSAP
printf( "8023_2_LSAP is not supported (yet?), DIX used instead\n" );
device->flags |= ETH_DIX;
device->flags |= ETH_8023_2_LSAP;
}else device->flags |= ETH_8023_2_SNAP;
if(( configuration[ 1 ].value ) && ( configuration[ 1 ].value[ 0 ] == 'y' )){
device->flags |= ETH_DUMMY;
382,7 → 380,7
return device->phone;
}
// get hardware address
if( ERROR_OCCURRED( netif_get_addr( device->phone, device->device_id, & device->addr, & device->addr_data ))){
if( ERROR_OCCURRED( netif_get_addr_req( device->phone, device->device_id, & device->addr, & device->addr_data ))){
fibril_rwlock_write_unlock( & eth_globals.devices_lock );
free( device );
return ERROR_CODE;
405,7 → 403,7
eth_proto_ref eth_process_packet( int flags, packet_t packet ){
ERROR_DECLARE;
 
eth_header_ex_ref header;
eth_header_snap_ref header;
size_t length;
eth_type_t type;
size_t prefix;
419,7 → 417,7
}
if( length < sizeof( eth_header_t ) + ETH_MIN_CONTENT + ( IS_DUMMY( flags ) ? ETH_SUFFIX : 0 )) return NULL;
data = packet_get_data( packet );
header = ( eth_header_ex_ref ) data;
header = ( eth_header_snap_ref ) data;
type = ntohs( header->header.ethertype );
if( type >= ETH_MIN_PROTO ){
// DIX Ethernet
566,7 → 564,8
}
 
int eth_prepare_packet( int flags, packet_t packet, uint8_t * src_addr, int ethertype, size_t mtu ){
eth_header_ex_ref header;
eth_header_snap_ref header;
eth_header_lsap_ref header_lsap;
eth_header_ref header_dix;
eth_fcs_ref fcs;
uint8_t * src;
592,8 → 591,7
for( i = 0; i < 7; ++ i ) preamble->preamble[ i ] = ETH_PREAMBLE;
preamble->sfd = ETH_SFD;
}
// TODO LSAP only device
if( IS_DIX( flags ) || IS_8023_2_LSAP( flags )){
if( IS_DIX( flags )){
header_dix = PACKET_PREFIX( packet, eth_header_t );
if( ! header_dix ) return ENOMEM;
header_dix->ethertype = ( uint16_t ) ethertype;
600,13 → 598,23
memcpy( header_dix->source_address, src_addr, ETH_ADDR );
memcpy( header_dix->destination_address, dest, ETH_ADDR );
src = & header_dix->destination_address[ 0 ];
}else if( IS_8023_2_LSAP( flags )){
header_lsap = PACKET_PREFIX( packet, eth_header_lsap_t );
if( ! header_lsap ) return ENOMEM;
header_lsap->header.ethertype = htons( length + sizeof( eth_header_lsap_t ));
header_lsap->lsap.dsap = lsap_unmap( ntohs( ethertype ));
header_lsap->lsap.ssap = header_lsap->lsap.dsap;
header_lsap->lsap.ctrl = IEEE_8023_2_UI;
memcpy( header_lsap->header.source_address, src_addr, ETH_ADDR );
memcpy( header_lsap->header.destination_address, dest, ETH_ADDR );
src = & header_lsap->header.destination_address[ 0 ];
}else if( IS_8023_2_SNAP( flags )){
header = PACKET_PREFIX( packet, eth_header_ex_t );
header = PACKET_PREFIX( packet, eth_header_snap_t );
if( ! header ) return ENOMEM;
header->header.ethertype = htons( length + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t ));
header->lsap.dsap = ( uint16_t ) ETH_LSAP_SNAP;
header->lsap.ssap = header->lsap.dsap;
header->lsap.ctrl = 0;
header->lsap.ctrl = IEEE_8023_2_UI;
for( i = 0; i < 3; ++ i ) header->snap.protocol[ i ] = 0;
header->snap.ethertype = ( uint16_t ) ethertype;
memcpy( header->header.source_address, src_addr, ETH_ADDR );