replaced tabs with 4 spaces.
This commit is contained in:
parent
b0dc373163
commit
f736245326
@ -15,9 +15,9 @@ struct udphdr;
|
||||
#define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark)
|
||||
|
||||
#ifdef CONFIG_NETWORK_SECMARK
|
||||
# define skb_secmark(skb) ((skb)->secmark)
|
||||
# define skb_secmark(skb) ((skb)->secmark)
|
||||
#else
|
||||
# define skb_secmark(skb) 0
|
||||
# define skb_secmark(skb) 0
|
||||
#endif
|
||||
|
||||
#endif /* COMPAT_SKBUFF_H */
|
||||
|
@ -16,47 +16,47 @@
|
||||
#define DEBUGP Use__pr_debug__instead
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
|
||||
# warning Kernels below 3.7 not supported.
|
||||
# warning Kernels below 3.7 not supported.
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
|
||||
# define prandom_u32() random32()
|
||||
# define prandom_u32() random32()
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||
# if !defined(CONFIG_NF_CONNTRACK_MARK)
|
||||
# warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
|
||||
# endif
|
||||
# include <net/netfilter/nf_conntrack.h>
|
||||
# if !defined(CONFIG_NF_CONNTRACK_MARK)
|
||||
# warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
|
||||
# endif
|
||||
# include <net/netfilter/nf_conntrack.h>
|
||||
#else
|
||||
# warning You need CONFIG_NF_CONNTRACK.
|
||||
# warning You need CONFIG_NF_CONNTRACK.
|
||||
#endif
|
||||
|
||||
#if !defined(NIP6) && !defined(NIP6_FMT)
|
||||
# define NIP6(addr) \
|
||||
ntohs((addr).s6_addr16[0]), \
|
||||
ntohs((addr).s6_addr16[1]), \
|
||||
ntohs((addr).s6_addr16[2]), \
|
||||
ntohs((addr).s6_addr16[3]), \
|
||||
ntohs((addr).s6_addr16[4]), \
|
||||
ntohs((addr).s6_addr16[5]), \
|
||||
ntohs((addr).s6_addr16[6]), \
|
||||
ntohs((addr).s6_addr16[7])
|
||||
# define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
|
||||
# define NIP6(addr) \
|
||||
ntohs((addr).s6_addr16[0]), \
|
||||
ntohs((addr).s6_addr16[1]), \
|
||||
ntohs((addr).s6_addr16[2]), \
|
||||
ntohs((addr).s6_addr16[3]), \
|
||||
ntohs((addr).s6_addr16[4]), \
|
||||
ntohs((addr).s6_addr16[5]), \
|
||||
ntohs((addr).s6_addr16[6]), \
|
||||
ntohs((addr).s6_addr16[7])
|
||||
# define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
|
||||
#endif
|
||||
#if !defined(NIPQUAD) && !defined(NIPQUAD_FMT)
|
||||
# define NIPQUAD(addr) \
|
||||
((const unsigned char *)&addr)[0], \
|
||||
((const unsigned char *)&addr)[1], \
|
||||
((const unsigned char *)&addr)[2], \
|
||||
((const unsigned char *)&addr)[3]
|
||||
# define NIPQUAD_FMT "%u.%u.%u.%u"
|
||||
# define NIPQUAD(addr) \
|
||||
((const unsigned char *)&addr)[0], \
|
||||
((const unsigned char *)&addr)[1], \
|
||||
((const unsigned char *)&addr)[2], \
|
||||
((const unsigned char *)&addr)[3]
|
||||
# define NIPQUAD_FMT "%u.%u.%u.%u"
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
|
||||
static inline struct inode *file_inode(struct file *f)
|
||||
{
|
||||
return f->f_path.dentry->d_inode;
|
||||
return f->f_path.dentry->d_inode;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -64,35 +64,35 @@ static inline struct inode *file_inode(struct file *f)
|
||||
static inline void proc_set_user(struct proc_dir_entry *de,
|
||||
typeof(de->uid) uid, typeof(de->gid) gid)
|
||||
{
|
||||
de->uid = uid;
|
||||
de->gid = gid;
|
||||
de->uid = uid;
|
||||
de->gid = gid;
|
||||
}
|
||||
|
||||
static inline void *PDE_DATA(struct inode *inode)
|
||||
{
|
||||
return PDE(inode)->data;
|
||||
return PDE(inode)->data;
|
||||
}
|
||||
|
||||
static inline void proc_remove(struct proc_dir_entry *de)
|
||||
{
|
||||
if (de != NULL)
|
||||
remove_proc_entry(de->name, de->parent);
|
||||
if (de != NULL)
|
||||
remove_proc_entry(de->name, de->parent);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
|
||||
# define ip6_local_out(xnet, xsk, xskb) ip6_local_out(xskb)
|
||||
# define ip6_route_me_harder(xnet, xskb) ip6_route_me_harder(xskb)
|
||||
# define ip_local_out(xnet, xsk, xskb) ip_local_out(xskb)
|
||||
# define ip_route_me_harder(xnet, xskb, xaddrtype) ip_route_me_harder((xskb), (xaddrtype))
|
||||
# define ip6_local_out(xnet, xsk, xskb) ip6_local_out(xskb)
|
||||
# define ip6_route_me_harder(xnet, xskb) ip6_route_me_harder(xskb)
|
||||
# define ip_local_out(xnet, xsk, xskb) ip_local_out(xskb)
|
||||
# define ip_route_me_harder(xnet, xskb, xaddrtype) ip_route_me_harder((xskb), (xaddrtype))
|
||||
#endif
|
||||
|
||||
static inline struct net *par_net(const struct xt_action_param *par)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
|
||||
return par->net;
|
||||
return par->net;
|
||||
#else
|
||||
return dev_net((par->in != NULL) ? par->in : par->out);
|
||||
return dev_net((par->in != NULL) ? par->in : par->out);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -14,50 +14,50 @@ struct module;
|
||||
struct sk_buff;
|
||||
|
||||
struct xtnu_match {
|
||||
/*
|
||||
* Making it smaller by sizeof(void *) on purpose to catch
|
||||
* lossy translation, if any.
|
||||
*/
|
||||
char name[sizeof(((struct xt_match *)NULL)->name) - 1 - sizeof(void *)];
|
||||
uint8_t revision;
|
||||
bool (*match)(const struct sk_buff *, struct xt_action_param *);
|
||||
int (*checkentry)(const struct xt_mtchk_param *);
|
||||
void (*destroy)(const struct xt_mtdtor_param *);
|
||||
struct module *me;
|
||||
const char *table;
|
||||
unsigned int matchsize, hooks;
|
||||
unsigned short proto, family;
|
||||
/*
|
||||
* Making it smaller by sizeof(void *) on purpose to catch
|
||||
* lossy translation, if any.
|
||||
*/
|
||||
char name[sizeof(((struct xt_match *)NULL)->name) - 1 - sizeof(void *)];
|
||||
uint8_t revision;
|
||||
bool (*match)(const struct sk_buff *, struct xt_action_param *);
|
||||
int (*checkentry)(const struct xt_mtchk_param *);
|
||||
void (*destroy)(const struct xt_mtdtor_param *);
|
||||
struct module *me;
|
||||
const char *table;
|
||||
unsigned int matchsize, hooks;
|
||||
unsigned short proto, family;
|
||||
|
||||
void *__compat_match;
|
||||
void *__compat_match;
|
||||
};
|
||||
|
||||
struct xtnu_target {
|
||||
char name[sizeof(((struct xt_target *)NULL)->name) - 1 - sizeof(void *)];
|
||||
uint8_t revision;
|
||||
unsigned int (*target)(struct sk_buff **,
|
||||
const struct xt_action_param *);
|
||||
int (*checkentry)(const struct xt_tgchk_param *);
|
||||
void (*destroy)(const struct xt_tgdtor_param *);
|
||||
struct module *me;
|
||||
const char *table;
|
||||
unsigned int targetsize, hooks;
|
||||
unsigned short proto, family;
|
||||
char name[sizeof(((struct xt_target *)NULL)->name) - 1 - sizeof(void *)];
|
||||
uint8_t revision;
|
||||
unsigned int (*target)(struct sk_buff **,
|
||||
const struct xt_action_param *);
|
||||
int (*checkentry)(const struct xt_tgchk_param *);
|
||||
void (*destroy)(const struct xt_tgdtor_param *);
|
||||
struct module *me;
|
||||
const char *table;
|
||||
unsigned int targetsize, hooks;
|
||||
unsigned short proto, family;
|
||||
|
||||
void *__compat_target;
|
||||
void *__compat_target;
|
||||
};
|
||||
|
||||
static inline struct xtnu_match *xtcompat_numatch(const struct xt_match *m)
|
||||
{
|
||||
void *q;
|
||||
memcpy(&q, m->name + sizeof(m->name) - sizeof(void *), sizeof(void *));
|
||||
return q;
|
||||
void *q;
|
||||
memcpy(&q, m->name + sizeof(m->name) - sizeof(void *), sizeof(void *));
|
||||
return q;
|
||||
}
|
||||
|
||||
static inline struct xtnu_target *xtcompat_nutarget(const struct xt_target *t)
|
||||
{
|
||||
void *q;
|
||||
memcpy(&q, t->name + sizeof(t->name) - sizeof(void *), sizeof(void *));
|
||||
return q;
|
||||
void *q;
|
||||
memcpy(&q, t->name + sizeof(t->name) - sizeof(void *), sizeof(void *));
|
||||
return q;
|
||||
}
|
||||
|
||||
extern int xtnu_register_match(struct xtnu_match *);
|
||||
|
@ -28,7 +28,7 @@ static void ts3init_get_cookie_help(void)
|
||||
static int ts3init_get_cookie_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
const void *entry, struct xt_entry_target **target)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ts3init_get_cookie_check(unsigned int flags)
|
||||
@ -38,13 +38,13 @@ static void ts3init_get_cookie_check(unsigned int flags)
|
||||
/* register and init */
|
||||
static struct xtables_target ts3init_get_cookie_tg_reg =
|
||||
{
|
||||
.name = "TS3INIT_GET_COOKIE",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.version = XTABLES_VERSION,
|
||||
.help = ts3init_get_cookie_help,
|
||||
.parse = ts3init_get_cookie_parse,
|
||||
.final_check = ts3init_get_cookie_check,
|
||||
.name = "TS3INIT_GET_COOKIE",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.version = XTABLES_VERSION,
|
||||
.help = ts3init_get_cookie_help,
|
||||
.parse = ts3init_get_cookie_parse,
|
||||
.final_check = ts3init_get_cookie_check,
|
||||
};
|
||||
|
||||
static __attribute__((constructor)) void ts3init_get_cookie_tg_ldr(void)
|
||||
|
@ -28,7 +28,7 @@ static void ts3init_reset_help(void)
|
||||
static int ts3init_reset_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
const void *entry, struct xt_entry_target **target)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ts3init_reset_check(unsigned int flags)
|
||||
@ -38,13 +38,13 @@ static void ts3init_reset_check(unsigned int flags)
|
||||
/* register and init */
|
||||
static struct xtables_target ts3init_reset_tg_reg =
|
||||
{
|
||||
.name = "TS3INIT_RESET",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.version = XTABLES_VERSION,
|
||||
.help = ts3init_reset_help,
|
||||
.parse = ts3init_reset_parse,
|
||||
.final_check = ts3init_reset_check,
|
||||
.name = "TS3INIT_RESET",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.version = XTABLES_VERSION,
|
||||
.help = ts3init_reset_help,
|
||||
.parse = ts3init_reset_parse,
|
||||
.final_check = ts3init_reset_check,
|
||||
};
|
||||
|
||||
static __attribute__((constructor)) void ts3init_reset_tg_ldr(void)
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
enum
|
||||
{
|
||||
TS3INIT_HEADER_CLIENT_LENGTH = 18,
|
||||
TS3INIT_HEADER_SERVER_LENGTH = 12,
|
||||
TS3INIT_HEADER_CLIENT_LENGTH = 18,
|
||||
TS3INIT_HEADER_SERVER_LENGTH = 12,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -84,10 +84,10 @@ static bool check_header(const struct sk_buff *skb, const struct xt_action_param
|
||||
return false;
|
||||
}
|
||||
|
||||
/* payload size check*/
|
||||
/* payload size check*/
|
||||
expected_payload_size = ts3init_payload_sizes[ts3_header->command];
|
||||
if (data_len != TS3INIT_HEADER_CLIENT_LENGTH + expected_payload_size)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
header_data->udp = udp;
|
||||
header_data->ts3_header = ts3_header;
|
||||
|
@ -31,8 +31,8 @@ struct xt_ts3init_get_cookie_mtinfo
|
||||
enum
|
||||
{
|
||||
CHK_GET_PUZZLE_CHECK_COOKIE = 1 << 0,
|
||||
CHK_GET_PUZZLE_RANDOM_SEED_FROM_ARGUMENT = 1 << 1,
|
||||
CHK_GET_PUZZLE_RANDOM_SEED_FROM_FILE = 1 << 2,
|
||||
CHK_GET_PUZZLE_RANDOM_SEED_FROM_ARGUMENT = 1 << 1,
|
||||
CHK_GET_PUZZLE_RANDOM_SEED_FROM_FILE = 1 << 2,
|
||||
CHK_GET_PUZZLE_VALID_MASK = (1 << 3) - 1,
|
||||
};
|
||||
|
||||
|
@ -33,16 +33,16 @@ MODULE_ALIAS("ip6t_ts3init");
|
||||
|
||||
static int __init ts3init_init(void)
|
||||
{
|
||||
int error;
|
||||
error = ts3init_match_init();
|
||||
if (error)
|
||||
int error;
|
||||
error = ts3init_match_init();
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = ts3init_target_init();
|
||||
if (error)
|
||||
error = ts3init_target_init();
|
||||
if (error)
|
||||
ts3init_match_exit();
|
||||
|
||||
return error;
|
||||
return error;
|
||||
}
|
||||
|
||||
static void __exit ts3init_exit(void)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
enum {
|
||||
RANDOM_SEED_LEN = 60,
|
||||
RANDOM_SEED_PATH_MAX = 256,
|
||||
RANDOM_SEED_PATH_MAX = 256,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -37,37 +37,37 @@ static inline bool parse_random_seed(const char *src, __u8* dst)
|
||||
*/
|
||||
static inline bool read_random_seed_from_file(const char *module_name, const char *path, __u8* dst)
|
||||
{
|
||||
int n, fd;
|
||||
char text[RANDOM_SEED_LEN * 2], error_message[256];
|
||||
if (strlen(path) > RANDOM_SEED_PATH_MAX)
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: path is too long.", module_name);
|
||||
return false;
|
||||
}
|
||||
int n, fd;
|
||||
char text[RANDOM_SEED_LEN * 2], error_message[256];
|
||||
if (strlen(path) > RANDOM_SEED_PATH_MAX)
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: path is too long.", module_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1) goto io_error;
|
||||
if (lseek(fd, 0, SEEK_END) == sizeof(text))
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s must contain exactly %lu characters", module_name, path, sizeof(text));
|
||||
return false;
|
||||
}
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) goto io_error;
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1) goto io_error;
|
||||
if (lseek(fd, 0, SEEK_END) == sizeof(text))
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s must contain exactly %lu characters", module_name, path, sizeof(text));
|
||||
return false;
|
||||
}
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) goto io_error;
|
||||
|
||||
n = read(fd, text, sizeof(text));
|
||||
if (n == -1) goto io_error;
|
||||
else if (n != sizeof(text) || parse_random_seed(text, dst) == false)
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s must contain exactly %lu lowercase hex characters", module_name, path, sizeof(text));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
n = read(fd, text, sizeof(text));
|
||||
if (n == -1) goto io_error;
|
||||
else if (n != sizeof(text) || parse_random_seed(text, dst) == false)
|
||||
{
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s must contain exactly %lu lowercase hex characters", module_name, path, sizeof(text));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
io_error:
|
||||
strerror_r(errno, error_message, sizeof(error_message));
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s.",
|
||||
module_name,
|
||||
error_message);
|
||||
return false;
|
||||
strerror_r(errno, error_message, sizeof(error_message));
|
||||
xtables_error(PARAMETER_PROBLEM, "%s: %s.",
|
||||
module_name,
|
||||
error_message);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user