summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-02-28 19:19:34 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-02-28 19:19:34 +0100
commit35742ca05a8826541207faaa9584708da5485d95 (patch)
treeba144fd8aa0ea1318916552ef647acae8c2694f7 /src/fastd.c
parentac0c534866ae9f4613143d2894631492d7df2e82 (diff)
downloadfastd-35742ca05a8826541207faaa9584708da5485d95.tar
fastd-35742ca05a8826541207faaa9584708da5485d95.zip
Replicate packets for each peer when sending
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 876975f..3594ffd 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -343,15 +343,17 @@ static void handle_input(fastd_context *ctx) {
dest_addr[0], dest_addr[1], dest_addr[2], dest_addr[3], dest_addr[4], dest_addr[5]);
// TODO find correct peer
- fastd_peer *peer = ctx->peers;
- if (peer->state == STATE_ESTABLISHED) {
- buffer.len = len;
- ctx->conf->method->method_send(ctx, peer, buffer);
- }
- else {
- fastd_buffer_free(buffer);
+ fastd_peer *peer;
+ for (peer = ctx->peers; peer; peer = peer->next) {
+ if (peer->state == STATE_ESTABLISHED) {
+ fastd_buffer send_buffer = fastd_buffer_alloc(len, 0);
+ memcpy(send_buffer.base, buffer.base, len);
+ ctx->conf->method->method_send(ctx, peer, send_buffer);
+ }
}
+
+ fastd_buffer_free(buffer);
}
if (fds[1].revents & POLLIN) {
size_t max_len = ctx->conf->method->method_max_packet_size(ctx);