Packet map and queue implementation. More...
#include <errno.h>#include <malloc.h>#include <mem.h>#include <fibril_synch.h>#include <unistd.h>#include <sys/mman.h>#include "../../err.h"#include "../generic_field.h"#include "packet.h"#include "packet_header.h"
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. | |
Typedefs | |
| typedef packet_t | packet_map_t [PACKET_MAP_SIZE] |
| Type definition of the packet map page. | |
| typedef packet_map_t * | packet_map_ref |
| Type definition of the packet map page pointer. | |
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) | |
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. | |
Variables | |
| struct { | |
| fibril_rwlock_t lock | |
| Safety lock. | |
| gpm_t packet_map | |
| Packet map. | |
| } | pm_globals |
| Packet map global data. | |
Packet map and queue implementation.
This file has to be compiled with both the packet server and the client.
| fibril_rwlock_t lock |
Safety lock.
Referenced by tcp_process_client_messages().
| gpm_t packet_map |
Packet map.
1.6.1