summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-07-23 19:48:46 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-07-23 19:48:46 +0200
commit945cc762afe999bdc9b30fa2818f64e7a5ae2db6 (patch)
tree16cce8aa878aeb08803e1bb764129f5c510e6be3 /src/peer.c
parentf0a655e9db3a46ab3f0c8bba7af548ff440ab98e (diff)
downloadfastd-945cc762afe999bdc9b30fa2818f64e7a5ae2db6.tar
fastd-945cc762afe999bdc9b30fa2818f64e7a5ae2db6.zip
Prepare for improved peer state handling
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/peer.c b/src/peer.c
index ebcb867..668b5c9 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -128,7 +128,7 @@ static bool is_peer_in_group(fastd_peer_t *peer, fastd_peer_group_t *group) {
}
static void reset_peer(fastd_context_t *ctx, fastd_peer_t *peer) {
- if (peer->established)
+ if (fastd_peer_is_established(peer))
on_disestablish(ctx, peer);
free_socket(ctx, peer);
@@ -160,7 +160,7 @@ static void setup_peer(fastd_context_t *ctx, fastd_peer_t *peer) {
memset(&peer->local_address, 0, sizeof(peer->local_address));
- peer->established = false;
+ peer->state = STATE_INIT;
peer->last_resolve = (struct timespec){0, 0};
peer->last_resolve_return = (struct timespec){0, 0};
@@ -463,13 +463,12 @@ void fastd_peer_enable_temporary(fastd_context_t *ctx, fastd_peer_t *peer) {
}
void fastd_peer_set_established(fastd_context_t *ctx, fastd_peer_t *peer) {
- if (!peer->established) {
- peer->established = true;
- on_establish(ctx, peer);
- pr_info(ctx, "connection with %P established.", peer);
- }
+ if (fastd_peer_is_established(peer))
+ return;
- return;
+ peer->state = STATE_ESTABLISHED;
+ on_establish(ctx, peer);
+ pr_info(ctx, "connection with %P established.", peer);
}
const fastd_eth_addr_t* fastd_get_source_address(const fastd_context_t *ctx, fastd_buffer_t buffer) {