Browse Source

renamed some symbols to keep namespace clear

pull/1/head
Niels Werensteijn 8 years ago
parent
commit
5712abbaa1
  1. 8
      src/ts3init_cache.c
  2. 6
      src/ts3init_cache.h
  3. 4
      src/ts3init_match.c
  4. 12
      src/ts3init_target.c

8
src/ts3init_cache.c

@ -46,7 +46,7 @@ static inline void update_cache_time(unsigned long jifs,
} }
} }
time_t get_cached_unix_time(void) time_t ts3init_get_cached_unix_time(void)
{ {
struct ts3init_cache_t* cache; struct ts3init_cache_t* cache;
unsigned long jifs; unsigned long jifs;
@ -65,7 +65,7 @@ time_t get_cached_unix_time(void)
return current_unix_time; return current_unix_time;
} }
bool get_cookie_for_package_index(u8 packet_index, const u8* seed, u64 (*cookie)[2]) bool ts3init_get_cookie_for_packet_index(u8 packet_index, const u8* seed, u64 (*cookie)[2])
{ {
struct ts3init_cache_t* cache; struct ts3init_cache_t* cache;
u64* result; u64* result;
@ -91,7 +91,7 @@ bool get_cookie_for_package_index(u8 packet_index, const u8* seed, u64 (*cookie)
return result; return result;
} }
bool get_current_cookie(const u8* seed, u64 (*cookie)[2], u8 *packet_index) bool ts3init_get_current_cookie(const u8* seed, u64 (*cookie)[2], u8 *packet_index)
{ {
struct ts3init_cache_t* cache; struct ts3init_cache_t* cache;
u64* result; u64* result;
@ -117,4 +117,4 @@ bool get_current_cookie(const u8* seed, u64 (*cookie)[2], u8 *packet_index)
} }
put_cpu_var(ts3init_cache); put_cpu_var(ts3init_cache);
return result; return result;
} }

6
src/ts3init_cache.h

@ -1,10 +1,10 @@
#ifndef _TS3INIT_CACHE_H #ifndef _TS3INIT_CACHE_H
#define _TS3INIT_CACHE_H #define _TS3INIT_CACHE_H
time_t get_cached_unix_time(void); time_t ts3init_get_cached_unix_time(void);
bool get_cookie_for_package_index(u8 packet_index, const u8* seed, u64 (*cookie)[2]); bool ts3init_get_cookie_for_packet_index(u8 packet_index, const u8* seed, u64 (*cookie)[2]);
bool get_current_cookie(const u8* seed, u64 (*cookie)[2], u8 *packet_index); bool ts3init_get_current_cookie(const u8* seed, u64 (*cookie)[2], u8 *packet_index);
#endif /* _TS3INIT_CACHE_H */ #endif /* _TS3INIT_CACHE_H */

4
src/ts3init_match.c

@ -97,7 +97,7 @@ ts3init_get_cookie_mt(const struct sk_buff *skb, struct xt_action_param *par)
{ {
time_t current_unix_time, packet_unix_time; time_t current_unix_time, packet_unix_time;
current_unix_time = get_cached_unix_time(); current_unix_time = ts3init_get_cached_unix_time();
packet_unix_time = packet_unix_time =
header_data.ts3_header->payload[0] << 24 | header_data.ts3_header->payload[0] << 24 |
@ -153,7 +153,7 @@ ts3init_get_puzzle_mt(const struct sk_buff *skb, struct xt_action_param *par)
__u64 cookie_seed[2]; __u64 cookie_seed[2];
__u64 cookie, packet_cookie; __u64 cookie, packet_cookie;
if (get_cookie_for_package_index(ts3_header->payload[8], info->cookie_seed, &cookie_seed) == false) if (ts3init_get_cookie_for_packet_index(ts3_header->payload[8], info->cookie_seed, &cookie_seed) == false)
return false; return false;
/* use cookie_seed and ipaddress and port to create a hash /* use cookie_seed and ipaddress and port to create a hash

12
src/ts3init_target.c

@ -245,7 +245,7 @@ ts3init_reset_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *par)
return NF_DROP; return NF_DROP;
} }
static const char set_cookie_package_header[12] = {'T', 'S', '3', 'I', 'N', 'I', 'T', '1', 0x65, 0, 0x88, COMMAND_SET_COOKIE }; static const char ts3init_set_cookie_package_header[12] = {'T', 'S', '3', 'I', 'N', 'I', 'T', '1', 0x65, 0, 0x88, COMMAND_SET_COOKIE };
static bool static bool
ts3init_generate_cookie_ipv4(const struct xt_action_param *par, ts3init_generate_cookie_ipv4(const struct xt_action_param *par,
@ -255,7 +255,7 @@ ts3init_generate_cookie_ipv4(const struct xt_action_param *par,
const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo; const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo;
__u64 cookie[2]; __u64 cookie[2];
if (get_current_cookie(info->cookie_seed, &cookie, packet_index) == false) if (ts3init_get_current_cookie(info->cookie_seed, &cookie, packet_index) == false)
return false; return false;
if (ts3init_calculate_cookie_ipv4(ip, udp, cookie[0], cookie[1], cookie_hash)) if (ts3init_calculate_cookie_ipv4(ip, udp, cookie[0], cookie[1], cookie_hash))
return false; return false;
@ -270,7 +270,7 @@ ts3init_generate_cookie_ipv6(const struct xt_action_param *par,
const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo; const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo;
__u64 cookie[2]; __u64 cookie[2];
if (get_current_cookie(info->cookie_seed, &cookie, packet_index) == false) if (ts3init_get_current_cookie(info->cookie_seed, &cookie, packet_index) == false)
return false; return false;
if (ts3init_calculate_cookie_ipv6(ip, udp, cookie[0], cookie[1], cookie_hash)) if (ts3init_calculate_cookie_ipv6(ip, udp, cookie[0], cookie[1], cookie_hash))
return false; return false;
@ -286,7 +286,7 @@ ts3init_fill_set_cookie_payload(const struct sk_buff *skb,
const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo; const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo;
u8 *payload, payload_buf[34]; u8 *payload, payload_buf[34];
memcpy(newpayload, set_cookie_package_header, sizeof(set_cookie_package_header)); memcpy(newpayload, ts3init_set_cookie_package_header, sizeof(ts3init_set_cookie_package_header));
newpayload[12] = (u8)cookie_hash; newpayload[12] = (u8)cookie_hash;
newpayload[13] = (u8)(cookie_hash >> 8); newpayload[13] = (u8)(cookie_hash >> 8);
newpayload[14] = (u8)(cookie_hash >> 16); newpayload[14] = (u8)(cookie_hash >> 16);
@ -327,7 +327,7 @@ ts3init_set_cookie_ipv4_tg(struct sk_buff *skb, const struct xt_action_param *pa
u8 *payload; u8 *payload;
u64 cookie_hash; u64 cookie_hash;
u8 packet_index; u8 packet_index;
const int payload_size = sizeof(set_cookie_package_header) + 20; const int payload_size = sizeof(ts3init_set_cookie_package_header) + 20;
if (ts3init_prepare_ipv4_reply(skb, par, payload_size, &newskb, &newip, &newudp, &payload)) if (ts3init_prepare_ipv4_reply(skb, par, payload_size, &newskb, &newip, &newudp, &payload))
{ {
@ -353,7 +353,7 @@ ts3init_set_cookie_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *pa
u8 *payload; u8 *payload;
u64 cookie_hash; u64 cookie_hash;
u8 packet_index; u8 packet_index;
const int payload_size = sizeof(set_cookie_package_header) + 20; const int payload_size = sizeof(ts3init_set_cookie_package_header) + 20;
if (ts3init_prepare_ipv6_reply(skb, par, payload_size, &newskb, &newip, &newudp, &payload)) if (ts3init_prepare_ipv6_reply(skb, par, payload_size, &newskb, &newip, &newudp, &payload))
{ {

Loading…
Cancel
Save