Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4557 → Rev 4558

/branches/network/uspace/srv/net/il/arp/arp.c
236,6 → 236,7
arp_device_ref device;
arp_proto_ref proto;
int index;
hw_type_t hardware;
 
rwlock_write_lock( & arp_globals.lock );
// an existing device?
266,8 → 267,8
printf( "New protocol added:\n\tdevice id\t= %d\n\tproto\t= %d", device_id, protocol );
}
}else{
index = hardware_map( service );
if( ! index ) return ENOENT;
hardware = hardware_map( service );
if( ! hardware ) return ENOENT;
// create a new device
device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
if( ! device ){
274,7 → 275,7
rwlock_write_unlock( & arp_globals.lock );
return ENOMEM;
}
device->hardware = index;
device->hardware = hardware;
device->device_id = device_id;
if( ERROR_OCCURRED( arp_protos_initialize( & device->protos ))
|| ERROR_OCCURRED( arp_proto_create( & proto, protocol, address ))){
291,7 → 292,7
}
device->service = service;
// bind the new one
device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_globals.client_connection );
device->phone = bind_service( device->service, ( ipcarg_t ) device->device_id, SERVICE_ARP, 0, arp_globals.client_connection );
if( device->phone < 0 ){
rwlock_write_unlock( & arp_globals.lock );
arp_protos_destroy( & device->protos );
363,9 → 364,9
return NULL;
}
header->hardware = htons( device->hardware );
header->hardware_length = device->addr->length;
header->hardware_length = ( uint8_t ) device->addr->length;
header->protocol = htons( protocol_map( device->service, protocol ));
header->protocol_length = proto->addr->length;
header->protocol_length = ( uint8_t ) proto->addr->length;
header->operation = htons( ARPOP_REQUEST );
length = sizeof( arp_header_t );
memcpy((( uint8_t * ) header ) + length, device->addr->value, device->addr->length );
402,7 → 403,8
if( ! device ) return ENOENT;
header = ( arp_header_ref ) packet_get_data( packet );
if(( ntohs( header->hardware ) != device->hardware )
|| ( length < sizeof( arp_header_t ) + ( header->hardware_length + header->protocol_length ) * 2 )){
// TODO how remove conversion from int '2' to uint?
|| ( length < sizeof( arp_header_t ) + ( header->hardware_length + header->protocol_length ) * 2u )){
return EINVAL;
}
proto = arp_protos_find( & device->protos, protocol_unmap( device->service, ntohs( header->protocol )));