61 lines
2.5 KiB
C
61 lines
2.5 KiB
C
#pragma once
|
|
#include <sys/socket.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include "evt_core.h"
|
|
#include "algo_utils.h"
|
|
#include "url.h"
|
|
#include "utils.h"
|
|
#include "packet.h"
|
|
|
|
void algo_naive_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap);
|
|
int algo_naive_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_naive_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_naive_on_err(struct evt_core_ctx *ctx, struct evt_core_fdinfo *fdinfo);
|
|
|
|
void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap);
|
|
int algo_rr_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_rr_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_rr_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
|
|
void algo_dup2_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap);
|
|
int algo_dup2_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_dup2_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp);
|
|
int algo_dup2_on_err(struct evt_core_ctx *ctx, struct evt_core_fdinfo *fdinfo);
|
|
|
|
static struct algo_desc available_algo[] = {
|
|
{
|
|
.name = "naive",
|
|
.init = algo_naive_init,
|
|
.on_stream = algo_naive_on_stream,
|
|
.on_datagram = algo_naive_on_datagram,
|
|
.on_err = algo_naive_on_err
|
|
},
|
|
{
|
|
.name = "rr",
|
|
.init = algo_rr_init,
|
|
.on_stream = algo_rr_on_stream,
|
|
.on_datagram = algo_rr_on_datagram,
|
|
.on_err = algo_rr_on_err
|
|
},
|
|
{
|
|
.name = "dup2",
|
|
.init = algo_dup2_init,
|
|
.on_stream = algo_dup2_on_stream,
|
|
.on_datagram = algo_dup2_on_datagram,
|
|
.on_err = algo_dup2_on_err
|
|
}
|
|
};
|
|
|
|
|
|
void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap);
|
|
|
|
int main_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_tcp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_udp_write (struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
|
int main_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|