Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4742 → Rev 4743

/branches/network/uspace/srv/net/tl/udp/udp.c
38,6 → 38,7
#include <async.h>
#include <fibril_sync.h>
#include <malloc.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
49,7 → 50,7
#include "../../structures/dynamic_fifo.h"
#include "../../structures/packet/packet_client.h"
 
#include "../../include/crc.h"
#include "../../include/checksum.h"
#include "../../include/in.h"
#include "../../include/in6.h"
#include "../../include/inet.h"
232,7 → 233,9
 
fibril_rwlock_write_lock( & udp_globals.lock );
result = udp_process_packet( packet, error );
fibril_rwlock_write_unlock( & udp_globals.lock );
if( result != EOK ){
fibril_rwlock_write_unlock( & udp_globals.lock );
}
 
return result;
}
379,6 → 382,7
}
 
// notify the destination socket
fibril_rwlock_write_unlock( & udp_globals.lock );
async_msg_5( socket->phone, NET_SOCKET_RECEIVED, ( ipcarg_t ) socket->socket_id, 0, 0, 0, ( ipcarg_t ) fragments );
return EOK;
}
414,7 → 418,7
 
/*
* Accept the connection
* - Answer the first IPC_M_CONNECT_ME_TO call.
* - Answer the first IPC_M_CONNECT_TO_ME call.
*/
ipc_answer_0( callid, EOK );
 
461,7 → 465,9
fibril_rwlock_read_lock( & lock );
fibril_rwlock_write_lock( & udp_globals.lock );
res = udp_sendto_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_GET_DATA_FRAGMENT_SIZE( call ), SOCKET_GET_FLAGS( call ));
fibril_rwlock_write_unlock( & udp_globals.lock );
if( res != EOK ){
fibril_rwlock_write_unlock( & udp_globals.lock );
}
fibril_rwlock_read_unlock( & lock );
free( addr );
}
527,24 → 533,24
 
if(( socket->port <= 0 ) && udp_globals.autobinding ){
// bind the socket to a random free port if not bound
do{
// do{
// try to find a free port
// fibril_rwlock_read_unlock( & udp_globals.lock );
// fibril_rwlock_write_lock( & udp_globals.lock );
// might be changed in the meantime
if( socket->port <= 0 ){
// if( socket->port <= 0 ){
if( ERROR_OCCURRED( socket_bind_free_port( & udp_globals.sockets, socket, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port ))){
fibril_rwlock_write_unlock( & udp_globals.lock );
fibril_rwlock_read_lock( & udp_globals.lock );
// fibril_rwlock_write_unlock( & udp_globals.lock );
// fibril_rwlock_read_lock( & udp_globals.lock );
return ERROR_CODE;
}
// set the next port as the search starting port number
udp_globals.last_used_port = socket->port;
}
// }
// fibril_rwlock_write_unlock( & udp_globals.lock );
// fibril_rwlock_read_lock( & udp_globals.lock );
// might be changed in the meantime
}while( socket->port <= 0 );
// }while( socket->port <= 0 );
}
 
// TODO do not ask all the time
602,7 → 608,9
return udp_release_and_return( packet, ERROR_CODE );
}
// send the packet
return ip_send_msg( udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0 );
fibril_rwlock_write_unlock( & udp_globals.lock );
ip_send_msg( udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0 );
return EOK;
}
 
int udp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen ){