summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-10-28 16:59:42 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-10-28 16:59:42 +0100
commit095ca93d81cfae0fcb137919231810577c556404 (patch)
treea5ee059d61dd5c0483657105fb2f5400350f3150
parent5f6177e00fe4c56ece2cabdd61b772ed040c6e19 (diff)
downloadfastd-095ca93d81cfae0fcb137919231810577c556404.tar
fastd-095ca93d81cfae0fcb137919231810577c556404.zip
Organize method and protocol source files into distinct source directories
-rw-r--r--CMakeLists.txt11
-rw-r--r--src/CMakeLists.txt34
-rw-r--r--src/fastd.c1
-rw-r--r--src/handshake.c1
-rw-r--r--src/methods/CMakeLists.txt19
-rw-r--r--src/methods/aes128_gcm/CMakeLists.txt6
-rw-r--r--src/methods/aes128_gcm/aes128_gcm.c (renamed from src/method_aes128_gcm.c)4
-rw-r--r--src/methods/null/CMakeLists.txt6
-rw-r--r--src/methods/null/null.c (renamed from src/method_null.c)2
-rw-r--r--src/methods/xsalsa20_poly1305/CMakeLists.txt6
-rw-r--r--src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c (renamed from src/method_xsalsa20_poly1305.c)3
-rw-r--r--src/options.c1
-rw-r--r--src/protocols/CMakeLists.txt10
-rw-r--r--src/protocols/ec25519_fhmqvc/CMakeLists.txt6
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c (renamed from src/protocol_ec25519_fhmqvc.c)9
-rw-r--r--src/types.h1
16 files changed, 86 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4490bc7..910ba33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,4 +145,15 @@ string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR)
configure_file(${FASTD_SOURCE_DIR}/config.h.in ${FASTD_BINARY_DIR}/config.h)
+add_custom_target(
+ version
+ COMMAND echo "#ifndef _FASTD_VERSION_H_" > ${FASTD_BINARY_DIR}/version.h.new
+ COMMAND echo "#define _FASTD_VERSION_H_" >> ${FASTD_BINARY_DIR}/version.h.new
+ COMMAND sh -c "echo \"#define FASTD_VERSION \\\"$(git --git-dir=./.git describe --dirty 2>/dev/null || echo ${FASTD_VERSION})\\\"\"" >> ${FASTD_BINARY_DIR}/version.h.new
+ COMMAND echo "#endif /* _FASTD_VERSION_H_ */" >> ${FASTD_BINARY_DIR}/version.h.new
+ COMMAND cmp -s ${FASTD_BINARY_DIR}/version.h.new ${FASTD_BINARY_DIR}/version.h && rm ${FASTD_BINARY_DIR}/version.h.new || mv ${FASTD_BINARY_DIR}/version.h.new ${FASTD_BINARY_DIR}/version.h
+ WORKING_DIRECTORY "${FASTD_SOURCE_DIR}"
+ VERBATIM
+)
+
add_subdirectory(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e962f7..99ff006 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,15 +1,13 @@
-set(METHODS method_null.c)
+set_directory_properties(PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
+set(FASTD_CFLAGS "-Wall -pthread ${UECC_CFLAGS_OTHER}")
-if(WITH_METHOD_XSALSA20_POLY1305)
- list(APPEND METHODS method_xsalsa20_poly1305.c)
-endif(WITH_METHOD_XSALSA20_POLY1305)
+include_directories(BEFORE ${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIR})
+link_directories(${UECC_LIBRARY_DIRS})
-if(WITH_METHOD_AES128_GCM)
- list(APPEND METHODS method_aes128_gcm.c)
-endif(WITH_METHOD_AES128_GCM)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CAP_INCLUDE_DIR} ${UECC_INCLUDE_DIRS} ${NACL_INCLUDE_DIR})
-link_directories(${UECC_LIBRARY_DIRS})
+add_subdirectory(protocols)
+add_subdirectory(methods)
+
BISON_TARGET(fastd_config_parse config.y ${CMAKE_CURRENT_BINARY_DIR}/config.yy.c)
@@ -32,26 +30,14 @@ add_executable(fastd
shell.c
socket.c
tuntap.c
- protocol_ec25519_fhmqvc.c
${BISON_fastd_config_parse_OUTPUTS}
- ${METHODS}
+ ${PROTOCOL_OBJECTS}
+ ${METHOD_OBJECTS}
)
-set_property(TARGET fastd PROPERTY COMPILE_FLAGS "-Wall -pthread ${UECC_CFLAGS_OTHER}")
-set_property(TARGET fastd PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
+set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
set_property(TARGET fastd PROPERTY LINK_FLAGS "-pthread ${UECC_LDFLAGS_OTHER}")
target_link_libraries(fastd ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARY})
-add_custom_target(
- version
- COMMAND echo "#ifndef _FASTD_VERSION_H_" > ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
- COMMAND echo "#define _FASTD_VERSION_H_" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
- COMMAND sh -c "echo \"#define FASTD_VERSION \\\"$(git --git-dir=./.git describe --dirty 2>/dev/null || echo ${FASTD_VERSION})\\\"\"" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
- COMMAND echo "#endif /* _FASTD_VERSION_H_ */" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
- COMMAND cmp -s ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h && rm ${CMAKE_CURRENT_BINARY_DIR}/version.h.new || mv ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h
- WORKING_DIRECTORY "${FASTD_SOURCE_DIR}"
- VERBATIM
-)
-
add_dependencies(fastd version)
install(TARGETS fastd RUNTIME DESTINATION bin)
diff --git a/src/fastd.c b/src/fastd.c
index f281744..c434216 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -28,6 +28,7 @@
#include "crypto.h"
#include "handshake.h"
#include "peer.h"
+#include <version.h>
#include <fcntl.h>
#include <grp.h>
diff --git a/src/handshake.c b/src/handshake.c
index 070c959..2986b90 100644
--- a/src/handshake.c
+++ b/src/handshake.c
@@ -26,6 +26,7 @@
#include "handshake.h"
#include "peer.h"
+#include <version.h>
static const char *const RECORD_TYPES[RECORD_MAX] = {
diff --git a/src/methods/CMakeLists.txt b/src/methods/CMakeLists.txt
new file mode 100644
index 0000000..55f41d2
--- /dev/null
+++ b/src/methods/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(METHODS null)
+
+if(WITH_METHOD_XSALSA20_POLY1305)
+ list(APPEND METHODS xsalsa20_poly1305)
+endif(WITH_METHOD_XSALSA20_POLY1305)
+
+if(WITH_METHOD_AES128_GCM)
+ list(APPEND METHODS aes128_gcm)
+endif(WITH_METHOD_AES128_GCM)
+
+
+set(METHOD_OBJECTS "")
+
+foreach(method ${METHODS})
+ add_subdirectory(${method})
+ list(APPEND METHOD_OBJECTS $<TARGET_OBJECTS:method_${method}>)
+endforeach(method)
+
+set(METHOD_OBJECTS "${METHOD_OBJECTS}" PARENT_SCOPE)
diff --git a/src/methods/aes128_gcm/CMakeLists.txt b/src/methods/aes128_gcm/CMakeLists.txt
new file mode 100644
index 0000000..1c5aa3f
--- /dev/null
+++ b/src/methods/aes128_gcm/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIR})
+
+add_library(method_aes128_gcm OBJECT
+ aes128_gcm.c
+)
+set_property(TARGET method_aes128_gcm PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
diff --git a/src/method_aes128_gcm.c b/src/methods/aes128_gcm/aes128_gcm.c
index 1b91925..46dba5c 100644
--- a/src/method_aes128_gcm.c
+++ b/src/methods/aes128_gcm/aes128_gcm.c
@@ -24,8 +24,8 @@
*/
-#include "fastd.h"
-#include "crypto.h"
+#include <fastd.h>
+#include <crypto.h>
#define KEYBYTES 16
diff --git a/src/methods/null/CMakeLists.txt b/src/methods/null/CMakeLists.txt
new file mode 100644
index 0000000..91c1832
--- /dev/null
+++ b/src/methods/null/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR})
+
+add_library(method_null OBJECT
+ null.c
+)
+set_property(TARGET method_null PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
diff --git a/src/method_null.c b/src/methods/null/null.c
index a978cb1..643e5e1 100644
--- a/src/method_null.c
+++ b/src/methods/null/null.c
@@ -24,7 +24,7 @@
*/
-#include "fastd.h"
+#include <fastd.h>
struct fastd_method_session_state {
diff --git a/src/methods/xsalsa20_poly1305/CMakeLists.txt b/src/methods/xsalsa20_poly1305/CMakeLists.txt
new file mode 100644
index 0000000..09b029c
--- /dev/null
+++ b/src/methods/xsalsa20_poly1305/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIR})
+
+add_library(method_xsalsa20_poly1305 OBJECT
+ xsalsa20_poly1305.c
+)
+set_property(TARGET method_xsalsa20_poly1305 PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
diff --git a/src/method_xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
index 395f322..d891aa5 100644
--- a/src/method_xsalsa20_poly1305.c
+++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
@@ -24,7 +24,8 @@
*/
-#include "fastd.h"
+#include <fastd.h>
+
#include <crypto_secretbox_xsalsa20poly1305.h>
diff --git a/src/options.c b/src/options.c
index 1462b9f..8d93bf9 100644
--- a/src/options.c
+++ b/src/options.c
@@ -26,6 +26,7 @@
#include "fastd.h"
#include "peer.h"
+#include <version.h>
#include <arpa/inet.h>
diff --git a/src/protocols/CMakeLists.txt b/src/protocols/CMakeLists.txt
new file mode 100644
index 0000000..f033d32
--- /dev/null
+++ b/src/protocols/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(PROTOCOLS ec25519_fhmqvc)
+
+set(PROTOCOL_OBJECTS "")
+
+foreach(protocol ${PROTOCOLS})
+ add_subdirectory(${protocol})
+ list(APPEND PROTOCOL_OBJECTS $<TARGET_OBJECTS:protocol_${protocol}>)
+endforeach(protocol)
+
+set(PROTOCOL_OBJECTS "${PROTOCOL_OBJECTS}" PARENT_SCOPE)
diff --git a/src/protocols/ec25519_fhmqvc/CMakeLists.txt b/src/protocols/ec25519_fhmqvc/CMakeLists.txt
new file mode 100644
index 0000000..ff1e246
--- /dev/null
+++ b/src/protocols/ec25519_fhmqvc/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${UECC_INCLUDE_DIRS})
+
+add_library(protocol_ec25519_fhmqvc OBJECT
+ ec25519_fhmqvc.c
+)
+set_property(TARGET protocol_ec25519_fhmqvc PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
index b7b5162..9fe1414 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
@@ -24,11 +24,10 @@
*/
-#include "fastd.h"
-#include "handshake.h"
-#include "peer.h"
-#include "sha256.h"
-
+#include <fastd.h>
+#include <handshake.h>
+#include <peer.h>
+#include <sha256.h>
#include <libuecc/ecc.h>
diff --git a/src/types.h b/src/types.h
index 16b1a5a..8e70326 100644
--- a/src/types.h
+++ b/src/types.h
@@ -34,7 +34,6 @@
#define _FASTD_TYPES_H_
#include <config.h>
-#include <version.h>
#include <stdbool.h>