Libpacket


Files

file  packet_server.c
 Packet server implementation.
file  packet_server.h
 Packet server.

Defines

#define DEFAULT_ADDR_LEN   32
 The default address length reserved for new packets.
#define DEFAULT_PREFIX   64
 The default prefix reserved for new packets.
#define DEFAULT_SUFFIX   64
 The default suffix reserved for new packets.
#define FREE_QUEUES_COUNT   7

Functions

static packet_tpacket_create (size_t length, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix)
 Creates a new packet of dimensions at least as given.
static packet_tpacket_get_local (size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix)
 Return the packet of dimensions at least as given.
static void packet_init (packet_t *packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix)
 Clears and initializes the packet according to the given dimensions.
static void packet_release (packet_t *packet)
 Release the packet and returns it to the appropriate free packet queue.
static int packet_release_wrapper (packet_id_t packet_id)
 Releases the packet queue.
static int packet_reply (packet_t *packet)
 Shares the packet memory block.
int packet_server_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count)
 Processes the packet server message.

Variables

struct {
   unsigned int   count
 Total packets allocated.
   packet_t *   free [FREE_QUEUES_COUNT]
 Free packet queues.
   fibril_mutex_t   lock
 Safety lock.
   size_t   sizes [FREE_QUEUES_COUNT]
 Packet length upper bounds of the free packet queues.
ps_globals
 Packet server global data.

Function Documentation

static packet_t* packet_create ( size_t  length,
size_t  addr_len,
size_t  max_prefix,
size_t  max_content,
size_t  max_suffix 
) [static]

Creates a new packet of dimensions at least as given.

Parameters:
[in] length The total length of the packet, including the header, the addresses and the data of the packet.
[in] addr_len The source and destination addresses maximal length in bytes.
[in] max_prefix The maximal prefix length in bytes.
[in] max_content The maximal content length in bytes.
[in] max_suffix The maximal suffix length in bytes.
Returns:
The packet of dimensions at least as given.

NULL if there is not enough memory left.

Definition at line 145 of file packet_server.c.

static packet_t* packet_get_local ( size_t  addr_len,
size_t  max_prefix,
size_t  max_content,
size_t  max_suffix 
) [static]

Return the packet of dimensions at least as given.

Try to reuse free packets first. Create a new packet aligned to the memory page size if none available. Lock the global data during its processing.

Parameters:
[in] addr_len The source and destination addresses maximal length in bytes.
[in] max_prefix The maximal prefix length in bytes.
[in] max_content The maximal content length in bytes.
[in] max_suffix The maximal suffix length in bytes.
Returns:
The packet of dimensions at least as given.

NULL if there is not enough memory left.

Definition at line 188 of file packet_server.c.

static void packet_init ( packet_t packet,
size_t  addr_len,
size_t  max_prefix,
size_t  max_content,
size_t  max_suffix 
) [static]

Clears and initializes the packet according to the given dimensions.

Parameters:
[in] packet The packet to be initialized.
[in] addr_len The source and destination addresses maximal length in bytes.
[in] max_prefix The maximal prefix length in bytes.
[in] max_content The maximal content length in bytes.
[in] max_suffix The maximal suffix length in bytes.

Definition at line 111 of file packet_server.c.

static void packet_release ( packet_t packet  )  [static]

Release the packet and returns it to the appropriate free packet queue.

Parameters:
[in] packet The packet to be released.

Definition at line 235 of file packet_server.c.

static int packet_release_wrapper ( packet_id_t  packet_id  )  [static]

Releases the packet queue.

Parameters:
[in] packet_id The first packet identifier.
Returns:
EOK on success.

ENOENT if there is no such packet.

Definition at line 258 of file packet_server.c.

static int packet_reply ( packet_t packet  )  [static]

Shares the packet memory block.

Parameters:
[in] packet The packet to be shared.
Returns:
EOK on success.

EINVAL if the packet is not valid.

EINVAL if the calling module does not accept the memory.

ENOMEM if the desired and actual sizes differ.

Other error codes as defined for the async_share_in_finalize() function.

Definition at line 282 of file packet_server.c.

int packet_server_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t answer_count 
)

Processes the packet server message.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
[out] answer The message answer parameters.
[out] answer_count The last parameter for the actual answer in the answer parameter.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

ENOENT if there is no such packet as in the packet message parameter.

ENOTSUP if the message is not known.

Other error codes as defined for the packet_release_wrapper() function.

Definition at line 320 of file packet_server.c.


Variable Documentation

size_t sizes[FREE_QUEUES_COUNT] [inherited]

Packet length upper bounds of the free packet queues.

The maximal lengths of packets in each queue in the ascending order. The last queue is not limited.

Definition at line 74 of file packet_server.c.


Generated on Thu Jun 2 07:45:57 2011 for HelenOS/USB by  doxygen 1.4.7