48,9 → 48,13 |
#include "../../messages.h" |
|
#include "packet.h" |
#include "packet_client.h" |
#include "packet_header.h" |
#include "packet_messages.h" |
#include "packet_server.h" |
|
#define FREE_QUEUES_COUNT 7 |
|
/** The default address length reserved for new packets. |
*/ |
#define DEFAULT_ADDR_LEN 32 |
63,28 → 67,6 |
*/ |
#define DEFAULT_SUFFIX 0 |
|
/** Returns the packet identifier message parameter. |
*/ |
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call ) |
|
/** Returns the maximal content length message parameter. |
*/ |
#define IPC_GET_CONTENT( call ) ( size_t ) IPC_GET_ARG1( * call ) |
|
/** Returns the maximal address length message parameter. |
*/ |
#define IPC_GET_ADDR_LEN( call ) ( size_t ) IPC_GET_ARG2( * call ) |
|
/** Returns the maximal prefix length message parameter. |
*/ |
#define IPC_GET_PREFIX( call ) ( size_t ) IPC_GET_ARG3( * call ) |
|
/** Returns the maximal suffix length message parameter. |
*/ |
#define IPC_GET_SUFFIX( call ) ( size_t ) IPC_GET_ARG4( * call ) |
|
#define FREE_QUEUES_COUNT 7 |
|
/** Packet server global data. |
*/ |
static struct{ |
109,12 → 91,6 |
0 |
}; |
|
/** Releases the packet and returns it to the appropriate free packet queue. |
* Should be used only when the global data are locked. |
* @param packet The packet to be released. Input parameter. |
*/ |
void packet_release( packet_t packet ); |
|
/** Returns the packet of dimensions at least as given. |
* Tries to reuse free packets first. |
* Creates a new packet aligned to the memory page size if none available. |
128,6 → 104,16 |
*/ |
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ); |
|
/** \todo |
*/ |
int packet_release_wrapper( packet_id_t packet_id ); |
|
/** Releases the packet and returns it to the appropriate free packet queue. |
* Should be used only when the global data are locked. |
* @param packet The packet to be released. Input parameter. |
*/ |
void packet_release( packet_t packet ); |
|
/** Creates a new packet of dimensions at least as given. |
* Should be used only when the global data are locked. |
* @param length The total length of the packet, including the header, the addresses and the data of the packet. Input parameter. |
159,6 → 145,24 |
*/ |
int packet_reply( const packet_t packet ); |
|
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){ |
if( ! packet ) return EINVAL; |
* packet = pm_find( packet_id ); |
return ( * packet ) ? EOK : ENOENT; |
} |
|
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){ |
return packet_get( addr_len, max_prefix, max_content, max_suffix ); |
} |
|
packet_t packet_get_1( int phone, size_t content ){ |
return packet_get( DEFAULT_ADDR_LEN, DEFAULT_PREFIX, content, DEFAULT_SUFFIX ); |
} |
|
void pq_release( int phone, packet_id_t packet_id ){ |
( void ) packet_release_wrapper( packet_id ); |
} |
|
int packet_server_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
packet_t packet; |
|
191,7 → 195,15 |
IPC_SET_ARG1( * answer, packet->length ); |
return EOK; |
case NET_PACKET_RELEASE: |
packet = pm_find( IPC_GET_ID( call )); |
return packet_release_wrapper( IPC_GET_ID( call )); |
} |
return ENOTSUP; |
} |
|
int packet_release_wrapper( packet_id_t packet_id ){ |
packet_t packet; |
|
packet = pm_find( packet_id ); |
if( ! packet_is_valid( packet )) return ENOENT; |
futex_down( & ps_globals.lock ); |
pq_destroy( packet, packet_release ); |
198,8 → 210,6 |
futex_up( & ps_globals.lock ); |
return EOK; |
} |
return ENOTSUP; |
} |
|
void packet_release( packet_t packet ){ |
int index; |