From 4582d4a9d2bd496f7c69699105703a9c719e989e Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 28 May 2019 15:47:31 +0200 Subject: [PATCH] Fix capture + send data --- src/capture_traffic.c | 2 +- src/meas_lat.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/capture_traffic.c b/src/capture_traffic.c index eee7baf..d1f0522 100644 --- a/src/capture_traffic.c +++ b/src/capture_traffic.c @@ -52,7 +52,7 @@ void traffic_capture_notify(struct capture_ctx* ctx, struct buffer_packet *bp, c dynbuf_append ( strcmp(dest, "in") == 0 ? &ctx->in : &ctx->out, - (char*)&bp, + (char*)bp, sizeof(struct buffer_packet)); } diff --git a/src/meas_lat.c b/src/meas_lat.c index 42961c2..2565a0e 100644 --- a/src/meas_lat.c +++ b/src/meas_lat.c @@ -41,6 +41,7 @@ struct measure_conf* create_measure_conf(int max_mes, int plsize) { perror("malloc failed"); exit(EXIT_FAILURE); } + return mc; } @@ -114,6 +115,15 @@ int on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { perror("clock_gettime error"); exit(EXIT_FAILURE); } + + char *my_msg = "Tu n'es pas tout a fait la misere,\nCar les levres les plus pauvres te denoncent\nPar un sourire."; + size_t msg_len = strlen(my_msg); + size_t cursor_msg = 0; + for (size_t i = sizeof(struct packet_header); i < mc->payload_size; i++) { + mc->payload[i] = my_msg[cursor_msg]; + cursor_msg = (cursor_msg + 1) % msg_len; + } + struct evt_core_fdinfo* tgtinfo = evt_core_get_first_from_cat (ctx, "udp-read"); if (tgtinfo == NULL) tgtinfo = evt_core_get_first_from_cat (ctx, "tcp-read"); if (tgtinfo == NULL) {