added 2 new constants: TS3INIT_HEADER_CLIENT_LENGTH and TS3INIT_HEADER_SERVER_LENGTH

This commit is contained in:
Maximilian Münchow 2016-10-13 14:21:11 +02:00
parent 2ed116a9ce
commit 52cc424be2
3 changed files with 10 additions and 4 deletions

View File

@ -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.
*/

View File

@ -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
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
/* 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;

View File

@ -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,