tor_multipath_voip/src/algo_utils.h

38 lines
2.1 KiB
C
Raw Permalink Normal View History

2019-03-07 15:57:02 +00:00
#pragma once
#include <glib-2.0/glib.h>
#include <glib-2.0/gmodule.h>
#include <glib-2.0/glib-object.h>
2019-04-24 14:23:41 +00:00
#include "packet.h"
#include "evt_core.h"
2019-05-24 14:16:39 +00:00
#define PACKET_BUFFER_SIZE 1024
2019-03-15 15:44:47 +00:00
2019-05-27 15:32:00 +00:00
struct buffer_resources {
2019-03-19 12:50:38 +00:00
struct buffer_packet bps[PACKET_BUFFER_SIZE];
2019-03-20 14:13:16 +00:00
GQueue* free_buffer; // Available buffers
GHashTable* used_buffer; // Buffers used for reading or writing
GQueue* read_waiting; // Who wait to be notified for a read
GHashTable* application_waiting; // Structure that can be used by the algo for its internal logic
GHashTable* write_waiting; // Structure to track packets waiting to be written
2019-03-07 15:57:02 +00:00
};
2019-05-27 15:32:00 +00:00
void init_buffer_management(struct buffer_resources* br);
void destroy_buffer_management(struct buffer_resources* br);
void mv_buffer_rtow(struct buffer_resources* app_ctx, struct evt_core_fdinfo* from, struct evt_core_fdinfo* to);
void mv_buffer_rtof(struct buffer_resources* app_ctx, struct evt_core_fdinfo* from);
void mv_buffer_wtof(struct buffer_resources* app_ctx, struct evt_core_fdinfo* from);
void mv_buffer_rtoa(struct buffer_resources* app_ctx, struct evt_core_fdinfo* from, void* to);
void mv_buffer_atow(struct buffer_resources* app_ctx, void* from, struct evt_core_fdinfo* to);
void mv_buffer_atof(struct buffer_resources* app_ctx, void* from);
2019-08-28 12:57:20 +00:00
struct buffer_packet* inject_buffer_tow(struct buffer_resources *app_ctx, struct evt_core_fdinfo* to);
2019-05-27 15:32:00 +00:00
struct buffer_packet* dup_buffer_tow(struct buffer_resources* app_ctx, struct buffer_packet* bp, struct evt_core_fdinfo* to);
2019-08-26 15:48:22 +00:00
struct buffer_packet* dup_buffer_toa(struct buffer_resources* app_ctx, struct buffer_packet* bp, void* to);
2019-05-27 15:32:00 +00:00
guint write_queue_len(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo);
2019-03-20 14:13:16 +00:00
2019-05-27 15:32:00 +00:00
struct buffer_packet* get_write_buffer(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo);
struct buffer_packet* get_read_buffer(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo);
struct buffer_packet* get_app_buffer(struct buffer_resources *app_ctx, void* idx);
2019-03-20 14:13:16 +00:00
2019-05-27 15:32:00 +00:00
void notify_read(struct evt_core_ctx* ctx, struct buffer_resources* app_ctx);
2019-03-20 14:13:16 +00:00