Browse Source

added 2 new constants: TS3INIT_HEADER_CLIENT_LENGTH and TS3INIT_HEADER_SERVER_LENGTH

pull/1/head
Maximilian Münchow 8 years ago
parent
commit
52cc424be2
  1. 6
      src/ts3init_header.h
  2. 6
      src/ts3init_match.c
  3. 2
      src/ts3init_target.c

6
src/ts3init_header.h

@ -1,6 +1,12 @@ @@ -1,6 +1,12 @@
#ifndef _TS3INIT_HEADER_H
#define _TS3INIT_HEADER_H
enum
{
TS3INIT_HEADER_CLIENT_LENGTH = 18,
TS3INIT_HEADER_SERVER_LENGTH = 12,
};
/*
* Magic number of a TS3INIT packet.
*/

6
src/ts3init_match.c

@ -37,7 +37,6 @@ struct ts3_init_checked_header_data @@ -37,7 +37,6 @@ struct ts3_init_checked_header_data
struct ts3_init_header* ts3_header, ts3_header_buf;
};
static const int header_size = 18;
static int ts3init_payload_sizes[] = { 16, 20, 20, 244, -1, 1 };
/*
@ -55,7 +54,7 @@ static bool check_header(const struct sk_buff *skb, const struct xt_action_param @@ -55,7 +54,7 @@ static bool check_header(const struct sk_buff *skb, const struct xt_action_param
udp = skb_header_pointer(skb, par->thoff, sizeof(*udp), &header_data->udp_buf);
data_len = be16_to_cpu(udp->len) - sizeof(*udp);
if (data_len < header_size ||
if (data_len < TS3INIT_HEADER_CLIENT_LENGTH ||
data_len > sizeof(header_data->ts3_header_buf))
return false;
@ -87,7 +86,8 @@ static bool check_header(const struct sk_buff *skb, const struct xt_action_param @@ -87,7 +86,8 @@ static bool check_header(const struct sk_buff *skb, const struct xt_action_param
/* payload size check*/
expected_payload_size = ts3init_payload_sizes[ts3_header->command];
if (data_len != header_size + expected_payload_size) return false;
if (data_len != TS3INIT_HEADER_CLIENT_LENGTH + expected_payload_size)
return false;
header_data->udp = udp;
header_data->ts3_header = ts3_header;

2
src/ts3init_target.c

@ -216,7 +216,7 @@ ts3init_reset_ipv6_tg(struct sk_buff *skb, const struct xt_action_param *par) @@ -216,7 +216,7 @@ 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[12] = {'T', 'S', '3', 'I', 'N', 'I', 'T', '1', 0x65, 0, 0x88, COMMAND_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,

Loading…
Cancel
Save