summaryrefslogtreecommitdiffstats
path: root/src/peer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/peer.h b/src/peer.h
index eec7bb0..f1187d8 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -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)