diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-27 19:01:31 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-27 19:01:31 +0200 |
commit | 21e4ada4bb0321250702c3af32d10f6a1bc65931 (patch) | |
tree | 65d55e026a0a682f2c789968b20657940db1e0f7 /src/peer.c | |
parent | cfadfce5484418ed88d235df8d82c14ebfe70d4c (diff) | |
download | fastd-21e4ada4bb0321250702c3af32d10f6a1bc65931.tar fastd-21e4ada4bb0321250702c3af32d10f6a1bc65931.zip |
Use configured peer names
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 54 |
1 files changed, 36 insertions, 18 deletions
@@ -31,24 +31,6 @@ #include "task.h" -const fastd_eth_addr* fastd_get_source_address(const fastd_context *ctx, fastd_buffer buffer) { - switch (ctx->conf->mode) { - case MODE_TAP: - return (fastd_eth_addr*)&((struct ethhdr*)buffer.data)->h_source; - default: - exit_bug(ctx, "invalid mode"); - } -} - -const fastd_eth_addr* fastd_get_dest_address(const fastd_context *ctx, fastd_buffer buffer) { - switch (ctx->conf->mode) { - case MODE_TAP: - return (fastd_eth_addr*)&((struct ethhdr*)buffer.data)->h_dest; - default: - exit_bug(ctx, "invalid mode"); - } -} - static inline void reset_peer(fastd_context *ctx, fastd_peer *peer) { ctx->conf->protocol->free_peer_state(ctx, peer); peer->protocol_state = NULL; @@ -81,6 +63,24 @@ static inline void setup_peer(fastd_context *ctx, fastd_peer *peer) { fastd_task_schedule_handshake(ctx, peer, 0); } + +fastd_peer_config* fastd_peer_config_new(fastd_context *ctx, fastd_config *conf) { + fastd_peer_config *peer = malloc(sizeof(fastd_peer_config)); + peer->enabled = true; + + memset(&peer->address, 0, sizeof(fastd_peer_address)); + + peer->name = NULL; + peer->key = NULL; + peer->protocol_config = NULL; + + peer->next = conf->peers; + conf->peers = peer; + + return peer; +} + + void fastd_peer_reset(fastd_context *ctx, fastd_peer *peer) { pr_debug(ctx, "resetting peer %P", peer); @@ -166,6 +166,24 @@ void fastd_peer_delete(fastd_context *ctx, fastd_peer *peer) { free(peer); } +const fastd_eth_addr* fastd_get_source_address(const fastd_context *ctx, fastd_buffer buffer) { + switch (ctx->conf->mode) { + case MODE_TAP: + return (fastd_eth_addr*)&((struct ethhdr*)buffer.data)->h_source; + default: + exit_bug(ctx, "invalid mode"); + } +} + +const fastd_eth_addr* fastd_get_dest_address(const fastd_context *ctx, fastd_buffer buffer) { + switch (ctx->conf->mode) { + case MODE_TAP: + return (fastd_eth_addr*)&((struct ethhdr*)buffer.data)->h_dest; + default: + exit_bug(ctx, "invalid mode"); + } +} + static inline int fastd_eth_addr_cmp(const fastd_eth_addr *addr1, const fastd_eth_addr *addr2) { return memcmp(addr1->data, addr2->data, ETH_ALEN); } |