Browse Source

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

pull/1/head
Maximilian Münchow 8 years ago
parent
commit
e1be5f7a25
  1. 4
      src/ts3init_cache.c
  2. 12
      src/ts3init_cache.h
  3. 4
      src/ts3init_cookie.h
  4. 2
      src/ts3init_match.c
  5. 26
      src/ts3init_target.c

4
src/ts3init_cache.c

@ -65,7 +65,7 @@ time_t ts3init_get_cached_unix_time(void) @@ -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, @@ -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;

12
src/ts3init_cache.h

@ -8,15 +8,15 @@ time_t ts3init_get_cached_unix_time(void); @@ -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 */

4
src/ts3init_cookie.h

@ -17,8 +17,8 @@ struct xt_ts3init_cookie_cache @@ -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,

2
src/ts3init_match.c

@ -217,7 +217,7 @@ static bool ts3init_get_puzzle_mt(const struct sk_buff *skb, struct xt_action_pa @@ -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

26
src/ts3init_target.c

@ -219,40 +219,38 @@ ts3init_reset_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *par) @@ -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;
}

Loading…
Cancel
Save