Packet management system
[Networking Stack]

Collaboration diagram for Packet management system:

Data Structures

struct  packet_dimension
 Packet dimension. More...
struct  packet
 Packet header. More...

Files

file  packet.c
 

Packet map and queue implementation.


file  packet.h
 

Packet map and queue.


file  packet_client.c
 

Packet client implementation.


file  packet_client.h
 

Packet client.


file  packet_header.h
 

Packet header.


file  packet_messages.h
 

Packet server module messages.


file  packet_remote.c
 

Packet client interface implementation for standalone remote modules.


file  packet_server.c
 

Packet server implementation.


file  packet_server.h
 

Packet server.


Defines

#define PACKET_MAP_SIZE   100
 Packet map page size.
#define PACKET_MAP_PAGE(packet_id)   (((packet_id) - 1) / PACKET_MAP_SIZE)
 Returns the packet map page index.
#define PACKET_MAP_INDEX(packet_id)   (((packet_id) - 1) % PACKET_MAP_SIZE)
 Returns the packet index in the corresponding packet map page.
#define PACKET_DATA_LENGTH(header)   ((header)->data_end - (header)->data_start)
 Returns the actual packet data length.
#define PACKET_MAX_ADDRESS_LENGTH(header)   ((header)->dest_addr - (header)->src_addr)
 Returns the maximum packet address length.
#define PACKET_MIN_SUFFIX(header)   ((header)->length - (header)->data_start - (header)->max_content)
 Returns the minimum packet suffix.
#define PACKET_MAGIC_VALUE   0x11227788
 Packet integrity check magic value.
#define ARP_GET_PROTO(call)   (services_t) IPC_GET_ARG2(*call)
 Returns the protocol service message parameter.
#define IPC_GET_ID(call)   (packet_id_t) IPC_GET_ARG1(*call)
 Returns the packet identifier message parameter.
#define IPC_GET_CONTENT(call)   (size_t) IPC_GET_ARG1(*call)
 Returns the maximal content length message parameter.
#define IPC_GET_ADDR_LEN(call)   (size_t) IPC_GET_ARG2(*call)
 Returns the maximal address length message parameter.
#define IPC_GET_PREFIX(call)   (size_t) IPC_GET_ARG3(*call)
 Returns the maximal prefix length message parameter.
#define IPC_GET_SUFFIX(call)   (size_t) IPC_GET_ARG4(*call)
 Returns the maximal suffix length message parameter.
#define FREE_QUEUES_COUNT   7
#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.

Typedefs

typedef packet_t packet_map_t [PACKET_MAP_SIZE]
 Type definition of the packet map page.
typedef packet_map_tpacket_map_ref
 Type definition of the packet map page pointer.
typedef int packet_id_t
 Packet identifier type.
typedef struct packetpacket_t
 Type definition of the packet.
typedef packet_tpacket_ref
 Type definition of the packet pointer.
typedef struct packet_dimension packet_dimension_t
 Type definition of the packet dimension.
typedef packet_dimension_tpacket_dimension_ref
 Type definition of the packet dimension pointer.

Enumerations

enum  packet_messages {
  NET_PACKET_CREATE_1 = NET_PACKET_FIRST, NET_PACKET_CREATE_4, NET_PACKET_GET, NET_PACKET_GET_SIZE,
  NET_PACKET_RELEASE
}
 

Packet server module messages.

More...

Functions

 GENERIC_FIELD_DECLARE (gpm, packet_map_t)
 Packet map.
int packet_destroy (packet_t packet)
 Releases the packet.
 GENERIC_FIELD_IMPLEMENT (gpm, packet_map_t)
static int packet_is_valid (const packet_t packet)
 Returns whether the packet is valid.
int packet_return (int phone, packet_ref packet, packet_id_t packet_id, size_t size)
 Obtains the packet from the packet server as the shared memory block.
int packet_server_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, int *answer_count)
 Processes the packet server message.

Variables

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

Packet management system interface



int pm_init (void)
 Initializes the packet map.
packet_t pm_find (packet_id_t packet_id)
 Finds the packet mapping.
int pm_add (packet_t packet)
 Adds the packet mapping.
void pm_destroy (void)
 Releases the packet map.
int pq_add (packet_t *first, packet_t packet, size_t order, size_t metric)
 Add packet to the sorted queue.
packet_t pq_find (packet_t first, size_t order)
 Finds the packet with the given order.
int pq_insert_after (packet_t packet, packet_t new_packet)
 Inserts packet after the given one.
packet_t pq_detach (packet_t packet)
 Detach the packet from the queue.
int pq_set_order (packet_t packet, size_t order, size_t metric)
 Sets the packet order and metric attributes.
int pq_get_order (packet_t packet, size_t *order, size_t *metric)
 Sets the packet order and metric attributes.
void pq_destroy (packet_t first, void(*packet_release)(packet_t packet))
 Releases the whole queue.
packet_t pq_next (packet_t packet)
 Returns the next packet in the queue.
packet_t pq_previous (packet_t packet)
 Returns the previous packet in the queue.

Packet client interface



int packet_copy_data (packet_t packet, const void *data, size_t length)
 Copies the specified data to the beginning of the actual packet content.
void * packet_prefix (packet_t packet, size_t length)
 Allocates the specified space right before the actual packet content and returns its pointer.
void * packet_suffix (packet_t packet, size_t length)
 Allocates the specified space right after the actual packet content and returns its pointer.
int packet_trim (packet_t packet, size_t prefix, size_t suffix)
 Trims the actual packet content by the specified prefix and suffix lengths.
packet_id_t packet_get_id (const packet_t packet)
 Returns the packet identifier.
int packet_get_addr (const packet_t packet, uint8_t **src, uint8_t **dest)
 Returns the stored packet addresses and their length.
size_t packet_get_data_length (const packet_t packet)
 Returns the packet content length.
void * packet_get_data (const packet_t packet)
 Returns the pointer to the beginning of the packet content.
int packet_set_addr (packet_t packet, const uint8_t *src, const uint8_t *dest, size_t addr_len)
 Sets the packet addresses.
packet_t packet_get_copy (int phone, packet_t packet)
 Returns the packet copy.
int packet_translate (int phone, packet_ref packet, packet_id_t packet_id)
 Translates the packet identifier to the packet reference.
packet_t packet_get_4 (int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix)
 Obtains the packet of the given dimensions.
packet_t packet_get_1 (int phone, size_t content)
 Obtains the packet of the given content size.
void pq_release (int phone, packet_id_t packet_id)
 Releases the packet queue.
#define PACKET_PREFIX(packet, type)   (type *) packet_prefix((packet), sizeof(type))
 Allocates the specified type right before the actual packet content and returns its pointer.
#define PACKET_SUFFIX(packet, type)   (type *) packet_suffix((packet), sizeof(type))
 Allocates the specified type right after the actual packet content and returns its pointer.
#define PACKET_TRIM(packet, prefix, suffix)   packet_trim((packet), sizeof(prefix), sizeof(suffix))
 Trims the actual packet content by the specified prefix and suffix types.

Packet server support functions



packet_t packet_get (size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix)
 Returns the packet of dimensions at least as given.
int packet_release_wrapper (packet_id_t packet_id)
 Releases the packet queue.
void packet_release (packet_t packet)
 Releases the packet and returns it to the appropriate free packet queue.
packet_t packet_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.
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.
int packet_reply (const packet_t packet)
 Shares the packet memory block.

Define Documentation

#define ARP_GET_PROTO ( call   )     (services_t) IPC_GET_ARG2(*call)

Returns the protocol service message parameter.

#define DEFAULT_ADDR_LEN   32

The default address length reserved for new packets.

#define DEFAULT_PREFIX   64

The default prefix reserved for new packets.

Referenced by packet_get_1().

#define DEFAULT_SUFFIX   64

The default suffix reserved for new packets.

Referenced by packet_get_1().

#define FREE_QUEUES_COUNT   7

Referenced by packet_get(), and packet_release().

#define IPC_GET_ADDR_LEN ( call   )     (size_t) IPC_GET_ARG2(*call)

Returns the maximal address length message parameter.

#define IPC_GET_CONTENT ( call   )     (size_t) IPC_GET_ARG1(*call)

Returns the maximal content length message parameter.

#define IPC_GET_ID ( call   )     (packet_id_t) IPC_GET_ARG1(*call)

Returns the packet identifier message parameter.

#define IPC_GET_PREFIX ( call   )     (size_t) IPC_GET_ARG3(*call)

Returns the maximal prefix length message parameter.

#define IPC_GET_SUFFIX ( call   )     (size_t) IPC_GET_ARG4(*call)

Returns the maximal suffix length message parameter.

#define PACKET_DATA_LENGTH ( header   )     ((header)->data_end - (header)->data_start)

Returns the actual packet data length.

Parameters:
[in] header The packet header.
#define PACKET_MAGIC_VALUE   0x11227788

Packet integrity check magic value.

Referenced by packet_create(), and packet_is_valid().

#define PACKET_MAP_INDEX ( packet_id   )     (((packet_id) - 1) % PACKET_MAP_SIZE)

Returns the packet index in the corresponding packet map page.

Parameters:
[in] packet_id The packet identifier.
#define PACKET_MAP_PAGE ( packet_id   )     (((packet_id) - 1) / PACKET_MAP_SIZE)

Returns the packet map page index.

Parameters:
[in] packet_id The packet identifier.
#define PACKET_MAP_SIZE   100

Packet map page size.

#define PACKET_MAX_ADDRESS_LENGTH ( header   )     ((header)->dest_addr - (header)->src_addr)

Returns the maximum packet address length.

Parameters:
[in] header The packet header.
#define PACKET_MIN_SUFFIX ( header   )     ((header)->length - (header)->data_start - (header)->max_content)

Returns the minimum packet suffix.

Parameters:
[in] header The packet header.
#define PACKET_PREFIX ( packet,
type   )     (type *) packet_prefix((packet), sizeof(type))

Allocates the specified type right before the actual packet content and returns its pointer.

The wrapper of the packet_prepend() function.

Parameters:
[in] packet The packet to be used.
[in] type The type to be allocated at the beginning of the packet content.
Returns:
The typed pointer to the allocated memory.
NULL if the packet is not valid.
NULL if there is not enough memory left.

Referenced by eth_prepare_packet(), icmp_echo(), icmp_prepare_packet(), tcp_send_message(), and udp_sendto_message().

#define PACKET_SUFFIX ( packet,
type   )     (type *) packet_suffix((packet), sizeof(type))

Allocates the specified type right after the actual packet content and returns its pointer.

The wrapper of the packet_append() function.

Parameters:
[in] packet The packet to be used.
[in] type The type to be allocated at the end of the packet content.
Returns:
The typed pointer to the allocated memory.
NULL if the packet is not valid.
NULL if there is not enough memory left.

Referenced by eth_prepare_packet(), and tcp_create_notification_packet().

#define PACKET_TRIM ( packet,
prefix,
suffix   )     packet_trim((packet), sizeof(prefix), sizeof(suffix))

Trims the actual packet content by the specified prefix and suffix types.

The wrapper of the packet_trim() function.

Parameters:
[in] packet The packet to be trimmed.
[in] prefix The type of the prefix to be removed from the beginning of the packet content.
[in] suffix The type of the suffix to be removed from the end of the packet content.
Returns:
EOK on success.
EINVAL if the packet is not valid.
ENOMEM if there is not enough memory left.

Typedef Documentation

Type definition of the packet dimension pointer.

See also:
packet_dimension

Type definition of the packet dimension.

See also:
packet_dimension
typedef int packet_id_t

Packet identifier type.

Value zero (0) is used as an invalid identifier.

Type definition of the packet map page pointer.

typedef packet_t packet_map_t[PACKET_MAP_SIZE]

Type definition of the packet map page.

typedef packet_t* packet_ref

Type definition of the packet pointer.

See also:
packet
typedef struct packet* packet_t

Type definition of the packet.

See also:
packet

Enumeration Type Documentation

Packet server module messages.

Enumerator:
NET_PACKET_CREATE_1 

Create packet message with specified content length.

See also:
packet_get_1()
NET_PACKET_CREATE_4 

Create packet message with specified address length, prefix, content and suffix.

See also:
packet_get_4()
NET_PACKET_GET 

Get packet message.

See also:
packet_return()
NET_PACKET_GET_SIZE 

Get packet size message.

See also:
packet_translate()
NET_PACKET_RELEASE 

Release packet message.

See also:
pq_release()

Function Documentation

GENERIC_FIELD_DECLARE ( gpm  ,
packet_map_t   
)

Packet map.

Maps packet identifiers to the packet references.

See also:
generic_field.h
GENERIC_FIELD_IMPLEMENT ( gpm  ,
packet_map_t   
)
int packet_copy_data ( packet_t  packet,
const void *  data,
size_t  length 
)

Copies the specified data to the beginning of the actual packet content.

Pushes the content end if needed.

Parameters:
[in] packet The packet to be filled.
[in] data The data to be copied.
[in] length The length of the copied data.
Returns:
EOK on success.
EINVAL if the packet is not valid.
ENOMEM if there is not enough memory left.
packet_t packet_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.

Should be used only when the global data are locked.

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.

References ERROR_DECLARE, ERROR_OCCURRED, length, magic_value, packet_id, packet_init(), PACKET_MAGIC_VALUE, pm_add(), and ps_globals.

Referenced by packet_get().

Here is the call graph for this function:

Here is the caller graph for this function:

int packet_destroy ( packet_t  packet  ) 

Releases the packet.

Parameters:
[in] packet The packet to be released.
Returns:
EOK on success.
EINVAL if the packet is not valid.

References length, and packet_is_valid().

Here is the call graph for this function:

packet_t packet_get ( size_t  addr_len,
size_t  max_prefix,
size_t  max_content,
size_t  max_suffix 
)

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. Locks 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.

References FREE_QUEUES_COUNT, length, next, packet_create(), packet_init(), packet_is_valid(), pm_find(), pq_detach(), and ps_globals.

Referenced by packet_get_1(), and packet_get_4().

Here is the call graph for this function:

Here is the caller graph for this function:

packet_t packet_get_1 ( int  phone,
size_t  content 
)

Obtains the packet of the given content size.

Contacts the packet server to return the appropriate packet.

Parameters:
[in] phone The packet server module phone.
[in] content The maximal content length in bytes.
Returns:
The packet reference.
NULL on error.

References DEFAULT_ADDR_LEN, DEFAULT_PREFIX, DEFAULT_SUFFIX, and packet_get().

Here is the call graph for this function:

packet_t packet_get_4 ( int  phone,
size_t  max_content,
size_t  addr_len,
size_t  max_prefix,
size_t  max_suffix 
)

Obtains the packet of the given dimensions.

Contacts the packet server to return the appropriate packet.

Parameters:
[in] phone The packet server module phone.
[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 reference.
NULL on error.

References packet_get().

Referenced by arp_translate_message(), icmp_echo(), ip_fragment_packet(), and tcp_create_notification_packet().

Here is the call graph for this function:

Here is the caller graph for this function:

int packet_get_addr ( const packet_t  packet,
uint8_t **  src,
uint8_t **  dest 
)

Returns the stored packet addresses and their length.

Parameters:
[in] packet The packet.
[out] src The source address. May be NULL if not desired.
[out] dest The destination address. May be NULL if not desired.
Returns:
The stored addresses length.
Zero (0) if the addresses are not present.
EINVAL if the packet is not valid.

Referenced by eth_prepare_packet(), icmp_process_packet(), ip_fragment_packet(), tcp_process_packet(), udp_process_packet(), and udp_recvfrom_message().

Here is the caller graph for this function:

packet_t packet_get_copy ( int  phone,
packet_t  packet 
)

Returns the packet copy.

Copies the addresses, data, order and metric values. Does not copy the queue placement.

Parameters:
[in] phone The packet server module phone.
[in] packet The original packet.
Returns:
The packet copy.
NULL on error.

Referenced by tcp_prepare_copy().

Here is the caller graph for this function:

void * packet_get_data ( const packet_t  packet  ) 

Returns the pointer to the beginning of the packet content.

Parameters:
[in] packet The packet.
Returns:
The pointer to the beginning of the packet content.
NULL if the packet is not valid.

Referenced by arp_receive_message(), eth_process_packet(), icmp_client_process_packet(), icmp_process_packet(), ip_fragment_packet(), ip_prepare_icmp(), ip_prepare_packet(), ip_process_packet(), irq_handler(), netif_send_message(), tcp_process_packet(), tcp_queue_prepare_packet(), tcp_send_prepare_packet(), udp_process_packet(), udp_recvfrom_message(), and udp_sendto_message().

Here is the caller graph for this function:

size_t packet_get_data_length ( const packet_t  packet  ) 
packet_id_t packet_get_id ( const packet_t  packet  ) 
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.

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.

Referenced by packet_create(), and packet_get().

Here is the caller graph for this function:

static int packet_is_valid ( const packet_t  packet  )  [inline, static]

Returns whether the packet is valid.

Parameters:
[in] packet The packet to be checked.
Returns:
true if the packet is not NULL and the magic value is correct.
false otherwise.

References magic_value, and PACKET_MAGIC_VALUE.

Referenced by packet_destroy(), packet_get(), packet_release_wrapper(), and packet_reply().

Here is the caller graph for this function:

void * packet_prefix ( packet_t  packet,
size_t  length 
)

Allocates the specified space right before the actual packet content and returns its pointer.

Parameters:
[in] packet The packet to be used.
[in] length The space length to be allocated at the beginning of the packet content.
Returns:
The pointer to the allocated memory.
NULL if there is not enough memory left.

Referenced by ip_prepare_packet().

Here is the caller graph for this function:

void packet_release ( packet_t  packet  ) 

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

Should be used only when the global data are locked.

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

References FREE_QUEUES_COUNT, length, pq_add(), and ps_globals.

Referenced by packet_release_wrapper().

Here is the call graph for this function:

Here is the caller graph for this function:

int packet_release_wrapper ( packet_id_t  packet_id  ) 

Releases the packet queue.

Parameters:
[in] packet_id The first packet identifier.
Returns:
EOK on success.
ENOENT if there is no such packet.

References packet_is_valid(), packet_release(), pm_find(), pq_destroy(), and ps_globals.

Referenced by pq_release().

Here is the call graph for this function:

Here is the caller graph for this function:

int packet_reply ( const packet_t  packet  ) 

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.

References length, and packet_is_valid().

Here is the call graph for this function:

int packet_return ( int  phone,
packet_ref  packet,
packet_id_t  packet_id,
size_t  size 
)

Obtains the packet from the packet server as the shared memory block.

Creates the local packet mapping as well.

Parameters:
[in] phone The packet server module phone.
[out] packet The packet reference pointer to store the received packet reference.
[in] packet_id The packet identifier.
[in] size The packet total size in bytes.
Returns:
EOK on success.
Other error codes as defined for the pm_add() function.
Other error codes as defined for the async_share_in_start() function.

References ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, NET_PACKET_GET, and pm_add().

Here is the call graph for this function:

int packet_server_message ( ipc_callid_t  callid,
ipc_call_t *  call,
ipc_call_t *  answer,
int *  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.

Referenced by module_message().

Here is the caller graph for this function:

int packet_set_addr ( packet_t  packet,
const uint8_t *  src,
const uint8_t *  dest,
size_t  addr_len 
)

Sets the packet addresses.

Parameters:
[in] packet The packet.
[in] src The new source address. May be NULL.
[in] dest The new destination address. May be NULL.
[in] addr_len The addresses length.
Returns:
EOK on success.
EINVAL if the packet is not valid.
ENOMEM if there is not enough memory left.

Referenced by arp_receive_message(), arp_translate_message(), eth_process_packet(), icmp_echo(), icmp_process_packet(), ip_deliver_local(), ip_fragment_packet_data(), ip_prepare_icmp(), ip_prepare_packet(), ip_process_packet(), and tcp_queue_prepare_packet().

Here is the caller graph for this function:

void * packet_suffix ( packet_t  packet,
size_t  length 
)

Allocates the specified space right after the actual packet content and returns its pointer.

Parameters:
[in] packet The packet to be used.
[in] length The space length to be allocated at the end of the packet content.
Returns:
The pointer to the allocated memory.
NULL if there is not enough memory left.

Referenced by arp_translate_message(), dp_pkt2user(), eth_prepare_packet(), icmp_echo(), ip_create_middle_header(), ip_fragment_packet(), and ip_fragment_packet_data().

Here is the caller graph for this function:

int packet_translate ( int  phone,
packet_ref  packet,
packet_id_t  packet_id 
)

Translates the packet identifier to the packet reference.

Tries to find mapping first. Contacts the packet server to share the packet if the mapping is not present.

Parameters:
[in] phone The packet server module phone.
[out] packet The packet reference.
[in] packet_id The packet identifier.
Returns:
EOK on success.
EINVAL if the packet parameter is NULL.
Other error codes as defined for the NET_PACKET_GET_SIZE message.
Other error codes as defined for the packet_return() function.

References pm_find().

Referenced by eth_receiver(), icmp_process_message(), nil_message(), nildummy_receiver(), tcp_recvfrom_message(), and udp_recvfrom_message().

Here is the call graph for this function:

Here is the caller graph for this function:

int packet_trim ( packet_t  packet,
size_t  prefix,
size_t  suffix 
)

Trims the actual packet content by the specified prefix and suffix lengths.

Parameters:
[in] packet The packet to be trimmed.
[in] prefix The prefix length to be removed from the beginning of the packet content.
[in] suffix The suffix length to be removed from the end of the packet content.
Returns:
EOK on success.
EINVAL if the packet is not valid.
ENOMEM if there is not enough memory left.

Referenced by eth_process_packet(), icmp_prepare_packet(), icmp_process_packet(), ip_deliver_local(), ip_fragment_packet(), ip_fragment_packet_data(), tcp_process_established(), tcp_process_listen(), tcp_process_packet(), tcp_process_syn_sent(), udp_process_packet(), and udp_recvfrom_message().

Here is the caller graph for this function:

int pm_add ( packet_t  packet  ) 

Adds the packet mapping.

Parameters:
[in] packet The packet to be remembered.
Returns:
EOK on success.
EINVAL if the packet is not valid.
EINVAL if the packet map is not initialized.
ENOMEM if there is not enough memory left.

Referenced by packet_create(), and packet_return().

Here is the caller graph for this function:

void pm_destroy ( void   ) 

Releases the packet map.

Referenced by module_start().

Here is the caller graph for this function:

packet_t pm_find ( packet_id_t  packet_id  ) 

Finds the packet mapping.

Parameters:
[in] packet_id The packet identifier to be found.
Returns:
The found packet reference.
NULL if the mapping does not exist.

Referenced by packet_get(), packet_release_wrapper(), and packet_translate().

Here is the caller graph for this function:

int pm_init ( void   ) 

Initializes the packet map.

Returns:
EOK on success.
ENOMEM if there is not enough memory left.

Referenced by module_start().

Here is the caller graph for this function:

int pq_add ( packet_t first,
packet_t  packet,
size_t  order,
size_t  metric 
)

Add packet to the sorted queue.

The queue is sorted in the ascending order. The packet is inserted right before the packets of the same order value.

Parameters:
[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet.
[in] packet The packet to be added.
[in] order The packet order value.
[in] metric The metric value of the packet.
Returns:
EOK on success.
EINVAL if the first parameter is NULL.
EINVAL if the packet is not valid.

Referenced by dp_pkt2user(), packet_release(), queue_packet(), tcp_process_acknowledgement(), tcp_process_established(), tcp_queue_packet(), and udp_sendto_message().

Here is the caller graph for this function:

void pq_destroy ( packet_t  first,
void(*)(packet_t packet packet_release 
)

Releases the whole queue.

Detaches all packets of the queue and calls the packet_release() for each of them.

Parameters:
[in] first The first packet of the queue.
[in] packet_release The releasing function called for each of the packets after its detachment.

Referenced by packet_release_wrapper().

Here is the caller graph for this function:

packet_t pq_detach ( packet_t  packet  ) 

Detach the packet from the queue.

Parameters:
[in] packet The packet to be detached.
Returns:
The next packet in the queue. If the packet is the first one of the queue, this becomes the new first one.
NULL if there is no packet left.
NULL if the packet is not valid.

Referenced by dp_send(), eth_send_message(), ip_prepare_icmp(), ip_receive_message(), ip_split_packet(), netif_send_message(), nil_received_msg(), packet_get(), tcp_process_acknowledgement(), tcp_process_established(), tcp_process_listen(), tcp_process_syn_sent(), tcp_send_packets(), and udp_process_packet().

Here is the caller graph for this function:

packet_t pq_find ( packet_t  first,
size_t  order 
)

Finds the packet with the given order.

Parameters:
[in] first The first packet of the queue.
[in] order The packet order value.
Returns:
The packet with the given order.
NULL if the first packet is not valid.
NULL if the packet is not found.

Referenced by tcp_get_packets_to_send(), and tcp_retransmit_packet().

Here is the caller graph for this function:

int pq_get_order ( packet_t  packet,
size_t *  order,
size_t *  metric 
)

Sets the packet order and metric attributes.

Parameters:
[in] packet The packet to be set.
[out] order The packet order value.
[out] metric The metric value of the packet.
Returns:
EOK on success.
EINVAL if the packet is invalid..

Referenced by tcp_get_packets_to_send(), tcp_process_acknowledgement(), tcp_process_established(), and tcp_retransmit_packet().

Here is the caller graph for this function:

int pq_insert_after ( packet_t  packet,
packet_t  new_packet 
)

Inserts packet after the given one.

Parameters:
[in] packet The packet in the queue.
[in] new_packet The new packet to be inserted.
Returns:
EOK on success.
EINVAL if etiher of the packets is invalid.

Referenced by ip_fragment_packet_data(), tcp_get_packets_to_send(), and tcp_process_established().

Here is the caller graph for this function:

packet_t pq_next ( packet_t  packet  ) 

Returns the next packet in the queue.

Parameters:
[in] packet The packet queue member.
Returns:
The next packet in the queue.
NULL if there is no next packet.
NULL if the packet is not valid.

Referenced by eth_send_message(), ip_prepare_packet(), ip_split_packet(), netif_send_message(), queue_packet(), tcp_get_packets_to_send(), tcp_process_established(), tcp_process_packet(), and udp_process_packet().

Here is the caller graph for this function:

packet_t pq_previous ( packet_t  packet  ) 

Returns the previous packet in the queue.

Parameters:
[in] packet The packet queue member.
Returns:
The previous packet in the queue.
NULL if there is no previous packet.
NULL if the packet is not valid.
void pq_release ( int  phone,
packet_id_t  packet_id 
)

Releases the packet queue.

All packets in the queue are marked as free for use. The packet queue may be one packet only. The module should not use the packets after this point until they are received or obtained again.

Parameters:
[in] phone The packet server module phone.
[in] packet_id The packet identifier.

References packet_release_wrapper().

Referenced by arp_translate_message(), eth_send_message(), icmp_process_echo_reply(), icmp_release_and_return(), ip_prepare_icmp(), ip_release_and_return(), ip_send_route(), ip_split_packet(), nil_received_msg(), socket_destroy_core(), tcp_get_packets_to_send(), tcp_process_acknowledgement(), tcp_process_established(), tcp_process_listen(), tcp_process_packet(), tcp_process_syn_received(), tcp_process_syn_sent(), tcp_recvfrom_message(), tcp_release_and_return(), tcp_send_prepare_packet(), udp_process_packet(), udp_recvfrom_message(), and udp_release_and_return().

Here is the call graph for this function:

Here is the caller graph for this function:

int pq_set_order ( packet_t  packet,
size_t  order,
size_t  metric 
)

Sets the packet order and metric attributes.

Parameters:
[in] packet The packet to be set.
[in] order The packet order value.
[in] metric The metric value of the packet.
Returns:
EOK on success.
EINVAL if the packet is invalid..

Referenced by tcp_process_established().

Here is the caller graph for this function:


Variable Documentation

unsigned { ... } count [inherited]

Total packets allocated.

packet_t { ... } free[FREE_QUEUES_COUNT] [inherited]

Free packet queues.

fibril_mutex_t { ... } lock [inherited]

Safety lock.

fibril_rwlock_t { ... } lock [inherited]

Safety lock.

gpm_t { ... } packet_map [inherited]

Packet map.

struct { ... } pm_globals [static]

Packet map global data.

struct { ... } ps_globals [static]

Packet server global data.

Referenced by packet_create(), packet_get(), packet_release(), and packet_release_wrapper().

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.


Generated on Thu Mar 11 20:48:15 2010 for Networking and TCP/IP stack for HelenOS system by  doxygen 1.6.1