Browse Source

renamed all comments, arguments, and variables that contain or are related to the final cookie value to `cookie`

pull/1/head
Maximilian Münchow 8 years ago
parent
commit
3b40dc3416
  1. 7
      src/ts3init_cookie.h
  2. 30
      src/ts3init_target.c

7
src/ts3init_cookie.h

@ -26,9 +26,10 @@ __u64* ts3init_get_cookie_seed(time_t current_time, __u8 packet_index, @@ -26,9 +26,10 @@ __u64* ts3init_get_cookie_seed(time_t current_time, __u8 packet_index,
const __u8* random_seed);
/*
* Returns the hash of cookie and source/destination address/port.
* Ip and udp are the recieved headers from the client, k0 and k1 are the
* cookie, and out is the resulting hash.
* Returns a valid cookie.
* The cookie is generated from a cookie seed and ip and port from the source
* and destination. Ip and udp are the recieved headers from the client,
* k0 and k1 are the cookie seed, and out is the resulting hash.
*/
int ts3init_calculate_cookie_ipv6(const struct ipv6hdr *ip, const struct udphdr *udp,
__u64 k0, __u64 k1, __u64* out);

30
src/ts3init_target.c

@ -261,21 +261,21 @@ ts3init_generate_cookie_ipv6(const struct xt_action_param *par, @@ -261,21 +261,21 @@ ts3init_generate_cookie_ipv6(const struct xt_action_param *par,
static bool
ts3init_fill_set_cookie_payload(const struct sk_buff *skb,
const struct xt_action_param *par,
const u64 cookie_hash, const u8 packet_index,
const u64 cookie, const u8 packet_index,
u8 *newpayload)
{
const struct xt_ts3init_set_cookie_tginfo *info = par->targinfo;
u8 *payload, payload_buf[34];
memcpy(newpayload, ts3init_set_cookie_packet_header, sizeof(ts3init_set_cookie_packet_header));
newpayload[12] = (u8)cookie_hash;
newpayload[13] = (u8)(cookie_hash >> 8);
newpayload[14] = (u8)(cookie_hash >> 16);
newpayload[15] = (u8)(cookie_hash >> 24);
newpayload[16] = (u8)(cookie_hash >> 32);
newpayload[17] = (u8)(cookie_hash >> 40);
newpayload[18] = (u8)(cookie_hash >> 48);
newpayload[19] = (u8)(cookie_hash >> 56);
newpayload[12] = (u8)cookie;
newpayload[13] = (u8)(cookie >> 8);
newpayload[14] = (u8)(cookie >> 16);
newpayload[15] = (u8)(cookie >> 24);
newpayload[16] = (u8)(cookie >> 32);
newpayload[17] = (u8)(cookie >> 40);
newpayload[18] = (u8)(cookie >> 48);
newpayload[19] = (u8)(cookie >> 56);
newpayload[20] = packet_index;
if (info->specific_options & TARGET_SET_COOKIE_ZERO_RANDOM_SEQUENCE)
{
@ -308,7 +308,7 @@ ts3init_set_cookie_ipv4_tg(struct sk_buff *skb, const struct xt_action_param *pa @@ -308,7 +308,7 @@ ts3init_set_cookie_ipv4_tg(struct sk_buff *skb, const struct xt_action_param *pa
{
struct iphdr *ip;
struct udphdr *udp, udp_buf;
u64 cookie_hash;
u64 cookie;
u8 packet_index;
u8 payload[sizeof(ts3init_set_cookie_packet_header) + 20];
@ -317,8 +317,8 @@ ts3init_set_cookie_ipv4_tg(struct sk_buff *skb, const struct xt_action_param *pa @@ -317,8 +317,8 @@ ts3init_set_cookie_ipv4_tg(struct sk_buff *skb, const struct xt_action_param *pa
if (udp == NULL || ntohs(udp->len) <= sizeof(*udp))
return NF_DROP;
if (ts3init_generate_cookie_ipv4(par, ip, udp, &cookie_hash, &packet_index) &&
ts3init_fill_set_cookie_payload(skb, par, cookie_hash, packet_index, payload))
if (ts3init_generate_cookie_ipv4(par, ip, udp, &cookie, &packet_index) &&
ts3init_fill_set_cookie_payload(skb, par, cookie, packet_index, payload))
{
ts3init_send_ipv4_reply(skb, par, ip, udp, payload, sizeof(payload));
}
@ -334,7 +334,7 @@ ts3init_set_cookie_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *pa @@ -334,7 +334,7 @@ ts3init_set_cookie_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *pa
{
struct ipv6hdr *ip;
struct udphdr *udp, udp_buf;
u64 cookie_hash;
u64 cookie;
u8 packet_index;
u8 payload[sizeof(ts3init_set_cookie_packet_header) + 20];
@ -343,8 +343,8 @@ ts3init_set_cookie_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *pa @@ -343,8 +343,8 @@ ts3init_set_cookie_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *pa
if (udp == NULL || ntohs(udp->len) <= sizeof(*udp))
return NF_DROP;
if (ts3init_generate_cookie_ipv6(par, ip, udp, &cookie_hash, &packet_index) &&
ts3init_fill_set_cookie_payload(skb, par, cookie_hash, packet_index, payload))
if (ts3init_generate_cookie_ipv6(par, ip, udp, &cookie, &packet_index) &&
ts3init_fill_set_cookie_payload(skb, par, cookie, packet_index, payload))
{
ts3init_send_ipv6_reply(skb, par, ip, udp, payload, sizeof(payload));
}

Loading…
Cancel
Save