From e1be5f7a256f2cf05155d8944c6732ed1a8021fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20M=C3=BCnchow?= Date: Fri, 14 Oct 2016 13:02:24 +0200 Subject: [PATCH] renamed all comments, arguments, and variables that contain or are related to the value that is generated by combining random_seed and the current time to cookie_seed --- src/ts3init_cache.c | 4 ++-- src/ts3init_cache.h | 12 ++++++------ src/ts3init_cookie.h | 4 ++-- src/ts3init_match.c | 2 +- src/ts3init_target.c | 26 ++++++++++++-------------- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/ts3init_cache.c b/src/ts3init_cache.c index 1356ac2..5caac07 100644 --- a/src/ts3init_cache.c +++ b/src/ts3init_cache.c @@ -65,7 +65,7 @@ time_t ts3init_get_cached_unix_time(void) return current_unix_time; } -bool ts3init_get_cookie_for_packet_index(u8 packet_index, const u8* random_seed, u64 (*cookie)[2]) +bool ts3init_get_cookie_seed_for_packet_index(u8 packet_index, const u8* random_seed, u64 (*cookie)[2]) { struct ts3init_cache_t* cache; u64* result; @@ -91,7 +91,7 @@ bool ts3init_get_cookie_for_packet_index(u8 packet_index, const u8* random_seed, return result; } -bool ts3init_get_current_cookie(const u8* random_seed, u64 (*cookie)[2], u8 *packet_index) +bool ts3init_get_current_cookie_seed(const u8* random_seed, u64 (*cookie)[2], u8 *packet_index) { struct ts3init_cache_t* cache; u64* result; diff --git a/src/ts3init_cache.h b/src/ts3init_cache.h index 31eb894..9acf902 100644 --- a/src/ts3init_cache.h +++ b/src/ts3init_cache.h @@ -8,15 +8,15 @@ time_t ts3init_get_cached_unix_time(void); /* - * Returns the cookie for a packet_index. - * If the cookie is not in the cache, it will be generated using the random seed. + * Returns the cookie seed for a packet_index. + * If the cookie seed is not in the cache, it will be generated using the random seed. */ -bool ts3init_get_cookie_for_packet_index(u8 packet_index, const u8* random_seed, u64 (*cookie)[2]); +bool ts3init_get_cookie_seed_for_packet_index(u8 packet_index, const u8* random_seed, u64 (*cookie)[2]); /* - * Returns the current cookie and packet_index. - * If the cookie is not in the cache, it will be generated using the random seed. + * Returns the current cookie seed and packet_index. + * If the cookie seed is not in the cache, it will be generated using the random seed. */ -bool ts3init_get_current_cookie(const u8* random_seed, u64 (*cookie)[2], u8 *packet_index); +bool ts3init_get_current_cookie_seed(const u8* random_seed, u64 (*cookie)[2], u8 *packet_index); #endif /* _TS3INIT_CACHE_H */ diff --git a/src/ts3init_cookie.h b/src/ts3init_cookie.h index ef441f4..76b4139 100644 --- a/src/ts3init_cookie.h +++ b/src/ts3init_cookie.h @@ -17,8 +17,8 @@ struct xt_ts3init_cookie_cache }; /* - * Returns the cookie that fits current_time and packet_index. - * If the cookie is missing in cache it will be generated using + * Returns the cookie seed that fits current_time and packet_index. + * If the cookie seed is missing in cache it will be generated using * random_seed and current_time */ __u64* ts3init_get_cookie_seed(time_t current_time, __u8 packet_index, diff --git a/src/ts3init_match.c b/src/ts3init_match.c index b229c9b..9404ae4 100644 --- a/src/ts3init_match.c +++ b/src/ts3init_match.c @@ -217,7 +217,7 @@ static bool ts3init_get_puzzle_mt(const struct sk_buff *skb, struct xt_action_pa __u64 cookie_seed[2]; __u64 cookie, packet_cookie; - if (ts3init_get_cookie_for_packet_index(ts3_header->payload[8], info->random_seed, &cookie_seed) == false) + if (ts3init_get_cookie_seed_for_packet_index(ts3_header->payload[8], info->random_seed, &cookie_seed) == false) return false; /* use cookie_seed and ipaddress and port to create a hash diff --git a/src/ts3init_target.c b/src/ts3init_target.c index 1856922..3cd4e61 100644 --- a/src/ts3init_target.c +++ b/src/ts3init_target.c @@ -219,40 +219,38 @@ ts3init_reset_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *par) /* The header replied by TS3INIT_SET_COOKIE. */ static const char ts3init_set_cookie_packet_header[TS3INIT_HEADER_SERVER_LENGTH] = {'T', 'S', '3', 'I', 'N', 'I', 'T', '1', 0x65, 0, 0x88, COMMAND_SET_COOKIE }; -/* - * Returns the current cookie hashed with source/destination address/port, - * and the current packet_index. +/* + * Returns the current cookie. */ static bool ts3init_generate_cookie_ipv4(const struct xt_action_param *par, const struct iphdr *ip, const struct udphdr *udp, - u64 *cookie_hash, u8 *packet_index) + u64 *cookie, u8 *packet_index) { const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo; - __u64 cookie[2]; + __u64 cookie_seed[2]; - if (ts3init_get_current_cookie(info->random_seed, &cookie, packet_index) == false) + if (ts3init_get_current_cookie_seed(info->random_seed, &cookie_seed, packet_index) == false) return false; - if (ts3init_calculate_cookie_ipv4(ip, udp, cookie[0], cookie[1], cookie_hash)) + if (ts3init_calculate_cookie_ipv4(ip, udp, cookie_seed[0], cookie_seed[1], cookie)) return false; return true; } -/* - * Returns the current cookie hashed with source/destination address/port, - * and the current packet_index. +/* + * Returns the current cookie. */ static bool ts3init_generate_cookie_ipv6(const struct xt_action_param *par, const struct ipv6hdr *ip, const struct udphdr *udp, - u64 *cookie_hash, u8 *packet_index) + u64 *cookie, u8 *packet_index) { const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo; - __u64 cookie[2]; + __u64 cookie_seed[2]; - if (ts3init_get_current_cookie(info->random_seed, &cookie, packet_index) == false) + if (ts3init_get_current_cookie_seed(info->random_seed, &cookie_seed, packet_index) == false) return false; - if (ts3init_calculate_cookie_ipv6(ip, udp, cookie[0], cookie[1], cookie_hash)) + if (ts3init_calculate_cookie_ipv6(ip, udp, cookie_seed[0], cookie_seed[1], cookie)) return false; return true; }