diff --git a/src/Makefile b/src/Makefile index 8c188f7..a4bec3b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,6 +3,7 @@ MODULES_DIR := /lib/modules/$(shell uname -r) KERNEL_DIR := ${MODULES_DIR}/build obj-m += xt_ts3init.o +xt_ts3init-objs += ts3init_module.o ts3init_match.o ts3init_cookie.o siphash24.o all: make -C ${KERNEL_DIR} M=$$PWD; diff --git a/src/ts3init_cookie.c b/src/ts3init_cookie.c index a3b2f0e..8a7162d 100644 --- a/src/ts3init_cookie.c +++ b/src/ts3init_cookie.c @@ -62,7 +62,7 @@ static void check_update_seed_cache(time_t time, __u8 index, crypto_free_hash(desc.tfm); } -static __u8* get_cookie_seed(time_t current_time, __u8 packet_index, +__u8* get_cookie_seed(time_t current_time, __u8 packet_index, struct xt_ts3init_cookie_cache* cache, const __u8* cookie_seed) { diff --git a/src/ts3init_cookie.h b/src/ts3init_cookie.h index ca27dc1..149b4ef 100644 --- a/src/ts3init_cookie.h +++ b/src/ts3init_cookie.h @@ -12,4 +12,8 @@ struct xt_ts3init_cookie_cache __u8 __attribute__((aligned(8))) seed[SHA512_SIZE*2]; }; +__u8* get_cookie_seed(time_t current_time, __u8 packet_index, + struct xt_ts3init_cookie_cache* cache, + const __u8* cookie_seed); + #endif /* _TS3INIT_COOKIE_H */ diff --git a/src/ts3init_match.c b/src/ts3init_match.c index 7131d04..9258bd6 100644 --- a/src/ts3init_match.c +++ b/src/ts3init_match.c @@ -280,3 +280,12 @@ static struct xt_match ts3init_mt_reg[] __read_mostly = { }, }; +int __init ts3init_match_init(void) +{ + return xt_register_matches(ts3init_mt_reg, ARRAY_SIZE(ts3init_mt_reg)); +} + +void __exit ts3init_match_exit(void) +{ + xt_unregister_matches(ts3init_mt_reg, ARRAY_SIZE(ts3init_mt_reg)); +} diff --git a/src/xt_ts3init.c b/src/ts3init_module.c similarity index 53% rename from src/xt_ts3init.c rename to src/ts3init_module.c index 0b954d1..ceacd44 100644 --- a/src/xt_ts3init.c +++ b/src/ts3init_module.c @@ -2,9 +2,8 @@ * "ts3init" extension for Xtables * * Description: A module to aid in ts3 spoof protection - * This file just includes the actual code files so that - * we do not have to export unneed symbols to the kernel - * while stil organizing code into logical files. + * This file sets up the module load and remove functions + * and module meta data. * * Authors: * Niels Werensteijn , 2016-10-03 @@ -14,9 +13,12 @@ * or 3 of the License, as published by the Free Software Foundation. */ -#include "siphash24.c" -#include "ts3init_cookie.c" -#include "ts3init_match.c" +#include +#include + +/* defined in ts3init_match.c */ +int __init ts3init_match_init(void); +void __exit ts3init_match_exit(void); MODULE_AUTHOR("Niels Werensteijn "); MODULE_DESCRIPTION("A module to aid in ts3 spoof protection"); @@ -24,15 +26,15 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("ipt_ts3init"); MODULE_ALIAS("ip6t_ts3init"); -static int __init ts3init_mt_init(void) +static int __init ts3init_init(void) { - return xt_register_matches(ts3init_mt_reg, ARRAY_SIZE(ts3init_mt_reg)); + return ts3init_match_init(); } -static void __exit ts3init_mt_exit(void) +static void __exit ts3init_exit(void) { - xt_unregister_matches(ts3init_mt_reg, ARRAY_SIZE(ts3init_mt_reg)); + ts3init_match_exit(); } -module_init(ts3init_mt_init); -module_exit(ts3init_mt_exit); +module_init(ts3init_init); +module_exit(ts3init_exit);