Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3912 → Rev 3990

/branches/network/uspace/srv/net/structures/packet/packet_client.c
41,7 → 41,6
#include <string.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
#include <sys/mman.h>
 
#include "../../err.h"
63,18 → 62,6
*/
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size );
 
packet_t packet_copy( int phone, services_t owner, const packet_t packet ){
packet_t new;
 
if( ! packet_is_valid( packet )) return NULL;
// new = ( packet_t ) mmap( NULL, packet->length, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0 );
// if( new == MAP_FAILED ) return NULL;
// memcpy( new, packet, packet->length );
new = packet_get_1( phone, owner, packet_get_data_length( packet ));
packet_copy_data( new, packet_get_data( packet ), packet_get_data_length( packet ));
return new;
}
 
int packet_copy_data( packet_t packet, const void * data, size_t length ){
if( ! packet_is_valid( packet )) return EINVAL;
if( packet->data_start + length >= packet->length ) return ENOMEM;
127,11 → 114,6
return ( void * ) packet + packet->data_start;
}
 
packet_mode_t packet_get_mode( const packet_t packet ){
if( packet_is_valid( packet )) return packet->mode;
return PM_ONE_WAY;
}
 
int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ){
size_t padding;
 
153,18 → 135,6
return EOK;
}
 
int packet_set_mode( packet_t packet, packet_mode_t mode ){
if( ! packet_is_valid( packet )) return EINVAL;
packet->mode = mode;
return EOK;
}
 
int packet_set_owner( packet_t packet, services_t owner ){
if( ! packet_is_valid( packet )) return EINVAL;
packet->owner = owner;
return EOK;
}
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
ERROR_DECLARE;
 
196,7 → 166,7
return result;
}
 
packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
ERROR_DECLARE;
 
packet_id_t packet_id;
203,7 → 173,7
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_5_2( phone, NET_PACKET_CREATE_5, owner, max_content, addr_len, max_prefix, max_suffix, & packet_id, & size ))
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
210,7 → 180,7
return packet;
}
 
packet_t packet_get_1( int phone, services_t owner, size_t content ){
packet_t packet_get_1( int phone, size_t content ){
ERROR_DECLARE;
 
packet_id_t packet_id;
217,7 → 187,7
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_2_2( phone, NET_PACKET_CREATE_1, owner, content, & packet_id, & size ))
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}