summaryrefslogtreecommitdiffstats
path: root/src/peer.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-02-26 01:02:35 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-02-26 01:02:35 +0100
commit4ab4858d5473c816cc526b296ae9da6c6956219d (patch)
tree67ac9253e6aa74a68699aa2a9e8e43d89e14c088 /src/peer.h
parent87b9b80a55d3567e76fc86d3abc7f3cfd6d92e6f (diff)
downloadfastd-4ab4858d5473c816cc526b296ae9da6c6956219d.tar
fastd-4ab4858d5473c816cc526b296ae9da6c6956219d.zip
Experimental support for accepting connections from unknown peers
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/peer.h b/src/peer.h
index 3be2d49..eb72435 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -51,6 +51,7 @@ struct fastd_peer {
struct timespec last_handshake_response;
fastd_peer_address_t last_handshake_response_address;
+ fastd_protocol_peer_config_t *protocol_config;
fastd_protocol_peer_state_t *protocol_state;
};
@@ -90,6 +91,9 @@ bool fastd_peer_config_equal(const fastd_peer_config_t *peer1, const fastd_peer_
void fastd_peer_reset(fastd_context_t *ctx, fastd_peer_t *peer);
void fastd_peer_delete(fastd_context_t *ctx, fastd_peer_t *peer);
fastd_peer_t* fastd_peer_add(fastd_context_t *ctx, fastd_peer_config_t *conf);
+fastd_peer_t* fastd_peer_add_temporary(fastd_context_t *ctx, fastd_socket_t *sock, const fastd_peer_address_t *addr);
+bool fastd_peer_verify_temporary(fastd_context_t *ctx, fastd_peer_t *peer);
+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);
bool fastd_peer_may_connect(fastd_context_t *ctx, fastd_peer_t *peer);
bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *peer, fastd_socket_t *sock, const fastd_peer_address_t *addr);
@@ -98,6 +102,10 @@ void fastd_peer_reset_socket(fastd_context_t *ctx, fastd_peer_t *peer);
const fastd_eth_addr_t* fastd_get_source_address(const fastd_context_t *ctx, fastd_buffer_t buffer);
const fastd_eth_addr_t* fastd_get_dest_address(const fastd_context_t *ctx, fastd_buffer_t buffer);
+static inline bool fastd_peer_allow_unknown(fastd_context_t *ctx) {
+ return ctx->conf->on_verify;
+}
+
static inline bool fastd_peer_config_is_floating(const fastd_peer_config_t *config) {
return ((config->hostname == NULL && config->address.sa.sa_family == AF_UNSPEC) || config->dynamic_float);
}
@@ -109,11 +117,15 @@ static inline bool fastd_peer_config_is_dynamic(const fastd_peer_config_t *confi
bool fastd_peer_config_matches_dynamic(const fastd_peer_config_t *config, const fastd_peer_address_t *addr);
static inline bool fastd_peer_is_floating(const fastd_peer_t *peer) {
- return fastd_peer_config_is_floating(peer->config);
+ return peer->config ? fastd_peer_config_is_floating(peer->config) : true;
}
static inline bool fastd_peer_is_dynamic(const fastd_peer_t *peer) {
- return fastd_peer_config_is_dynamic(peer->config);
+ return peer->config ? fastd_peer_config_is_dynamic(peer->config) : false;
+}
+
+static inline bool fastd_peer_is_temporary(const fastd_peer_t *peer) {
+ return (!peer->config);
}
static inline bool fastd_peer_is_established(const fastd_peer_t *peer) {