summaryrefslogtreecommitdiffstats
path: root/src/peer.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-29 11:53:34 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-29 11:53:34 +0200
commit620f1cd45f44eb2dc2d9dd16bdf6ba4512a1bd69 (patch)
treeb499f013579302ee0c57538a8879d56c86dd756c /src/peer.h
parentdcaf41a18e1bd9014d1cf3ca7a7129a1be76e811 (diff)
downloadfastd-620f1cd45f44eb2dc2d9dd16bdf6ba4512a1bd69.tar
fastd-620f1cd45f44eb2dc2d9dd16bdf6ba4512a1bd69.zip
Replace old task queue
The handshakes are now schedules in a doubly-linked list that is maintained as a part of the peer structure.
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/peer.h b/src/peer.h
index 39b17a8..4d87e3a 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -28,7 +28,6 @@
#define _FASTD_PEER_H_
#include "fastd.h"
-#include "task.h"
struct fastd_peer {
@@ -48,6 +47,9 @@ struct fastd_peer {
fastd_remote_t *remotes;
fastd_remote_t *next_remote;
+ struct timespec next_handshake;
+ fastd_dlist_head_t handshake_entry;
+
struct timespec last_handshake;
fastd_peer_address_t last_handshake_address;
@@ -136,9 +138,14 @@ bool fastd_peer_owns_address(fastd_context_t *ctx, const fastd_peer_t *peer, con
bool fastd_peer_matches_address(fastd_context_t *ctx, const fastd_peer_t *peer, const fastd_peer_address_t *addr);
bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *peer, fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr);
void fastd_peer_reset_socket(fastd_context_t *ctx, fastd_peer_t *peer);
+void fastd_peer_schedule_handshake(fastd_context_t *ctx, fastd_peer_t *peer, int delay);
+
+static inline void fastd_peer_schedule_handshake_default(fastd_context_t *ctx, fastd_peer_t *peer) {
+ fastd_peer_schedule_handshake(ctx, peer, fastd_rand(ctx, 17500, 22500));
+}
-static inline void fastd_peer_schedule_handshake(fastd_context_t *ctx, fastd_peer_t *peer) {
- fastd_task_schedule_handshake(ctx, peer, fastd_rand(ctx, 17500, 22500));
+static inline void fastd_peer_unschedule_handshake(fastd_context_t *ctx UNUSED, fastd_peer_t *peer) {
+ fastd_dlist_remove(&peer->handshake_entry);
}
const fastd_eth_addr_t* fastd_get_source_address(const fastd_context_t *ctx, fastd_buffer_t buffer);