diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-19 00:10:48 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-19 00:21:38 +0200 |
commit | 35a18b1dea21f006b38694dcf5c99f817411ad4d (patch) | |
tree | c6922a55085eba524ad9a997816429c6437b7430 /src/peer.h | |
parent | 21ade840c989e9fcebef63e2999f5c31843c47b6 (diff) | |
download | fastd-35a18b1dea21f006b38694dcf5c99f817411ad4d.tar fastd-35a18b1dea21f006b38694dcf5c99f817411ad4d.zip |
Create peer structures for disabled peers as well
We have a 1:1 association between peers and peer configs now.
Diffstat (limited to 'src/peer.h')
-rw-r--r-- | src/peer.h | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -37,7 +37,8 @@ /** The state of a peer */ typedef enum fastd_peer_state { - STATE_INIT = 0, /**< The peer peer was just created */ + STATE_INACTIVE = 0, /**< The peer is not active at the moment */ + STATE_PASSIVE, /**< The peer is waiting for incoming connections */ STATE_RESOLVING, /**< The peer is currently resolving its first remote */ STATE_HANDSHAKE, /**< The peer has tried to perform a handshake */ STATE_ESTABLISHED, /**< The peer has established a connection */ @@ -45,8 +46,9 @@ typedef enum fastd_peer_state { /** The config state of a peer */ typedef enum fastd_peer_config_state { - CONFIG_DISABLED = 0, /**< The peer is configured statically, but has been not yet been enabled or disabled because of a configuration error */ + CONFIG_NEW = 0, /**< The peer is configured statically, but has been not been enabled yet */ CONFIG_STATIC, /**< The peer is configured statically */ + CONFIG_DISABLED, /**< The peer is configured statically, but has been disabled because of a configuration error */ #ifdef WITH_DYNAMIC_PEERS CONFIG_DYNAMIC, /**< The peer is configured dynamically (using a on-verify handler) */ #endif @@ -245,6 +247,19 @@ static inline bool fastd_peer_is_dynamic(const fastd_peer_t *peer UNUSED) { #endif } +/** Checks if a peer is enabled */ +static inline bool fastd_peer_is_enabled(const fastd_peer_t *peer) { + switch (peer->config->config_state) { + case CONFIG_STATIC: +#ifdef WITH_DYNAMIC_PEERS + case CONFIG_DYNAMIC: +#endif + return true; + default: + return false; + } +} + /** Returns the currently active remote entry */ static inline fastd_remote_t * fastd_peer_get_next_remote(fastd_peer_t *peer) { if (peer->next_remote < 0) |