From cd47acaf3cc874f8d26acca56fa6cef6110d946d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 2 Nov 2013 16:57:11 +0100 Subject: Move a few prototypes from fastd.h into a new config.h --- src/CMakeLists.txt | 2 +- src/config.c | 1 + src/config.h | 55 ++++++++++++++++++++++++ src/config.y | 5 ++- src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt | 2 +- src/crypto/cipher/ciphers.c.in | 3 +- src/crypto/mac/ghash/builtin/CMakeLists.txt | 2 +- src/crypto/mac/macs.c.in | 3 +- src/fastd.c | 1 + src/fastd.h | 22 ---------- src/methods/generic_gcm/CMakeLists.txt | 2 +- src/methods/methods.c.in | 2 +- src/methods/null/CMakeLists.txt | 2 +- src/methods/xsalsa20_poly1305/CMakeLists.txt | 2 +- src/options.c | 1 + src/protocols/ec25519_fhmqvc/CMakeLists.txt | 2 +- 16 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 src/config.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6545e8..dc5b8a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ set_directory_properties(PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE) set(FASTD_CFLAGS "-Wall -pthread ${UECC_CFLAGS_OTHER} ${NACL_CFLAGS_OTHER}") -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS}) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS}) link_directories(${UECC_LIBRARY_DIRS} ${NACL_LIBRARY_DIRS}) diff --git a/src/config.c b/src/config.c index f9d2ae1..f46bb68 100644 --- a/src/config.c +++ b/src/config.c @@ -25,6 +25,7 @@ #include "fastd.h" +#include "config.h" #include "lex.h" #include "peer.h" #include diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..a4777c7 --- /dev/null +++ b/src/config.h @@ -0,0 +1,55 @@ +/* + Copyright (c) 2012-2013, Matthias Schiffer + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef _FASTD_CONFIG_H_ +#define _FASTD_CONFIG_H_ + +#include "fastd.h" + + +bool fastd_config_protocol(fastd_context_t *ctx, fastd_config_t *conf, const char *name); +bool fastd_config_method(fastd_context_t *ctx, fastd_config_t *conf, const char *name); +bool fastd_config_add_log_file(fastd_context_t *ctx, fastd_config_t *conf, const char *name, fastd_loglevel_t level); +bool fastd_config_bind_address(fastd_context_t *ctx, fastd_config_t *conf, const fastd_peer_address_t *address, const char *bindtodev, bool default_v4, bool default_v6); +void fastd_config_peer_group_push(fastd_context_t *ctx, fastd_config_t *conf, const char *name); +void fastd_config_peer_group_pop(fastd_context_t *ctx, fastd_config_t *conf); +void fastd_config_release(fastd_context_t *ctx, fastd_config_t *conf); +void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]); +void fastd_config_load_peer_dirs(fastd_context_t *ctx, fastd_config_t *conf); +void fastd_config_handle_options(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]); + +void fastd_add_peer_dir(fastd_context_t *ctx, fastd_config_t *conf, const char *dir); +bool fastd_read_config(fastd_context_t *ctx, fastd_config_t *conf, const char *filename, bool peer_config, int depth); + +const fastd_cipher_t** fastd_cipher_config_alloc(void); +void fastd_cipher_config_free(const fastd_cipher_t **cipher_conf); +bool fastd_cipher_config(const fastd_cipher_t **cipher_conf, const char *name, const char *impl); + +const fastd_mac_t** fastd_mac_config_alloc(void); +void fastd_mac_config_free(const fastd_mac_t **mac_conf); +bool fastd_mac_config(const fastd_mac_t **mac_conf, const char *name, const char *impl); + +#endif /* _FASTD_CONFIG_H_ */ diff --git a/src/config.y b/src/config.y index 4efbde5..a79e8e9 100644 --- a/src/config.y +++ b/src/config.y @@ -34,7 +34,7 @@ %parse-param {int depth} %code requires { - #include + #include #include } @@ -125,7 +125,8 @@ %code { - #include + #include + #include #include diff --git a/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt b/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt index ecbca70..60479ab 100644 --- a/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt +++ b/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src ${NACL_INCLUDE_DIRS}) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src ${NACL_INCLUDE_DIRS}) add_library(cipher_aes128_ctr_nacl OBJECT cipher_aes128_ctr_nacl.c diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in index 37de211..5bedc75 100644 --- a/src/crypto/cipher/ciphers.c.in +++ b/src/crypto/cipher/ciphers.c.in @@ -24,7 +24,8 @@ */ -#include +#include +#include @CIPHER_DEFINITIONS@ diff --git a/src/crypto/mac/ghash/builtin/CMakeLists.txt b/src/crypto/mac/ghash/builtin/CMakeLists.txt index 907c3dd..4e8208b 100644 --- a/src/crypto/mac/ghash/builtin/CMakeLists.txt +++ b/src/crypto/mac/ghash/builtin/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src) add_library(mac_ghash_builtin OBJECT ghash_builtin.c diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in index 5a4e1fb..7d8a5ff 100644 --- a/src/crypto/mac/macs.c.in +++ b/src/crypto/mac/macs.c.in @@ -24,7 +24,8 @@ */ -#include +#include +#include @MAC_DEFINITIONS@ diff --git a/src/fastd.c b/src/fastd.c index 175dc00..6c2b9e5 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -25,6 +25,7 @@ #include "fastd.h" +#include "config.h" #include "handshake.h" #include "peer.h" #include diff --git a/src/fastd.h b/src/fastd.h index 573da1b..0f62445 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -361,40 +361,18 @@ void fastd_resolve_peer(fastd_context_t *ctx, fastd_peer_t *peer, fastd_remote_t int fastd_vsnprintf(const fastd_context_t *ctx, char *buffer, size_t size, const char *format, va_list ap); void fastd_logf(const fastd_context_t *ctx, fastd_loglevel_t level, const char *format, ...); -void fastd_add_peer_dir(fastd_context_t *ctx, fastd_config_t *conf, const char *dir); -bool fastd_read_config(fastd_context_t *ctx, fastd_config_t *conf, const char *filename, bool peer_config, int depth); - const fastd_method_t* fastd_method_get_by_name(const char *name); -const fastd_cipher_t** fastd_cipher_config_alloc(void); -void fastd_cipher_config_free(const fastd_cipher_t **cipher_conf); -bool fastd_cipher_config(const fastd_cipher_t **cipher_conf, const char *name, const char *impl); - void fastd_cipher_init(fastd_context_t *ctx); void fastd_cipher_free(fastd_context_t *ctx); bool fastd_cipher_available(const char *name); const fastd_cipher_t* fastd_cipher_get_by_name(fastd_context_t *ctx, const char *name, fastd_cipher_context_t **cctx); -const fastd_mac_t** fastd_mac_config_alloc(void); -void fastd_mac_config_free(const fastd_mac_t **mac_conf); -bool fastd_mac_config(const fastd_mac_t **mac_conf, const char *name, const char *impl); - void fastd_mac_init(fastd_context_t *ctx); void fastd_mac_free(fastd_context_t *ctx); bool fastd_mac_available(const char *name); const fastd_mac_t* fastd_mac_get_by_name(fastd_context_t *ctx, const char *name, fastd_mac_context_t **cctx); -bool fastd_config_protocol(fastd_context_t *ctx, fastd_config_t *conf, const char *name); -bool fastd_config_method(fastd_context_t *ctx, fastd_config_t *conf, const char *name); -bool fastd_config_add_log_file(fastd_context_t *ctx, fastd_config_t *conf, const char *name, fastd_loglevel_t level); -bool fastd_config_bind_address(fastd_context_t *ctx, fastd_config_t *conf, const fastd_peer_address_t *address, const char *bindtodev, bool default_v4, bool default_v6); -void fastd_config_peer_group_push(fastd_context_t *ctx, fastd_config_t *conf, const char *name); -void fastd_config_peer_group_pop(fastd_context_t *ctx, fastd_config_t *conf); -void fastd_config_release(fastd_context_t *ctx, fastd_config_t *conf); -void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]); -void fastd_config_load_peer_dirs(fastd_context_t *ctx, fastd_config_t *conf); -void fastd_config_handle_options(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]); - void fastd_tuntap_open(fastd_context_t *ctx); fastd_buffer_t fastd_tuntap_read(fastd_context_t *ctx); void fastd_tuntap_write(fastd_context_t *ctx, fastd_buffer_t buffer); diff --git a/src/methods/generic_gcm/CMakeLists.txt b/src/methods/generic_gcm/CMakeLists.txt index 732e7ed..8c22292 100644 --- a/src/methods/generic_gcm/CMakeLists.txt +++ b/src/methods/generic_gcm/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src) add_library(method_generic_gcm OBJECT generic_gcm.c diff --git a/src/methods/methods.c.in b/src/methods/methods.c.in index 8a8958c..2a8d9fb 100644 --- a/src/methods/methods.c.in +++ b/src/methods/methods.c.in @@ -24,7 +24,7 @@ */ -#include +#include @METHOD_DEFINITIONS@ diff --git a/src/methods/null/CMakeLists.txt b/src/methods/null/CMakeLists.txt index 0e68fec..d65a342 100644 --- a/src/methods/null/CMakeLists.txt +++ b/src/methods/null/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src) add_library(method_null OBJECT null.c diff --git a/src/methods/xsalsa20_poly1305/CMakeLists.txt b/src/methods/xsalsa20_poly1305/CMakeLists.txt index 3c9e2cf..66dcb7e 100644 --- a/src/methods/xsalsa20_poly1305/CMakeLists.txt +++ b/src/methods/xsalsa20_poly1305/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src ${NACL_INCLUDE_DIRS}) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src ${NACL_INCLUDE_DIRS}) add_library(method_xsalsa20_poly1305 OBJECT xsalsa20_poly1305.c diff --git a/src/options.c b/src/options.c index cf53991..f7dd88f 100644 --- a/src/options.c +++ b/src/options.c @@ -25,6 +25,7 @@ #include "fastd.h" +#include "config.h" #include "peer.h" #include diff --git a/src/protocols/ec25519_fhmqvc/CMakeLists.txt b/src/protocols/ec25519_fhmqvc/CMakeLists.txt index f39fba8..d637a25 100644 --- a/src/protocols/ec25519_fhmqvc/CMakeLists.txt +++ b/src/protocols/ec25519_fhmqvc/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}/src ${UECC_INCLUDE_DIRS}) +include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src ${UECC_INCLUDE_DIRS}) add_library(protocol_ec25519_fhmqvc OBJECT ec25519_fhmqvc.c -- cgit v1.2.3