Add unpad function
This commit is contained in:
parent
298d0f7f26
commit
4d5dd554c5
1 changed files with 29 additions and 5 deletions
|
@ -8,15 +8,16 @@
|
|||
// A Tor cell size is 512 bytes but handle only 498 bytes of data
|
||||
#define TOR_CELL_SIZE 498
|
||||
#define ALLOWED_JITTER_MS 200
|
||||
#define MAX_LINKS 64
|
||||
|
||||
struct thunder_ctx {
|
||||
uint16_t recv_id;
|
||||
uint16_t emit_id;
|
||||
uint8_t selected_link;
|
||||
uint8_t total_links;
|
||||
uint8_t delta_t_per_link[64];
|
||||
uint64_t received_pkts_on_link[64];
|
||||
uint8_t blacklisted[64];
|
||||
uint8_t delta_t_per_link[MAX_LINKS];
|
||||
uint64_t received_pkts_on_link[MAX_LINKS];
|
||||
uint8_t blacklisted[MAX_LINKS];
|
||||
size_t monit_pkt_size;
|
||||
struct timespec prev_link_time, prev_packet_time;
|
||||
};
|
||||
|
@ -193,8 +194,29 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
|||
}
|
||||
}
|
||||
|
||||
void unpad() {
|
||||
struct unpad_info {
|
||||
union abstract_packet *ap_arr_pl[MAX_LINKS], *ap_arr_meta[MAX_LINKS];
|
||||
uint8_t ap_arr_vals;
|
||||
};
|
||||
|
||||
void unpad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp, struct unpad_info *ui) {
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||
|
||||
for (union abstract_packet* ap = buffer_first_ap (bp); ap != NULL; ap = ap_next(ap)) {
|
||||
if (ap->fmt.headers.cmd != CMD_UDP_ENCAPSULATED) continue;
|
||||
|
||||
union abstract_packet* ap_meta = ap_next(ap);
|
||||
if (ap_meta == NULL || ap_meta->fmt.headers.cmd != CMD_UDP_METADATA_THUNDER) {
|
||||
fprintf(stderr, "Unexpected packet, expecting udp metadata\n");
|
||||
}
|
||||
|
||||
if (ap_meta->fmt.content.udp_metadata_thunder.id > thunderc->recv_id) {
|
||||
ui->ap_arr_pl[ui->ap_arr_vals] = ap;
|
||||
ui->ap_arr_meta[ui->ap_arr_vals] = ap_meta;
|
||||
ui->ap_arr_vals++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adapt() {
|
||||
|
@ -202,8 +224,10 @@ void adapt() {
|
|||
}
|
||||
|
||||
int algo_thunder_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||
struct unpad_info ui = {0};
|
||||
|
||||
classify(ctx, fdinfo, bp);
|
||||
unpad();
|
||||
unpad(ctx, fdinfo, bp, &ui);
|
||||
adapt();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue