2005-04-16 22:20:36 +00:00
|
|
|
/* Hop Limit matching module */
|
|
|
|
|
|
|
|
/* (C) 2001-2002 Maciej Soltysiak <solt@dns.toxicfilms.tv>
|
|
|
|
* Based on HW's ttl module
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2007-02-07 23:11:19 +00:00
|
|
|
#include <linux/ipv6.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
|
|
|
|
#include <linux/netfilter_ipv6/ip6t_hl.h>
|
2007-02-07 23:11:19 +00:00
|
|
|
#include <linux/netfilter/x_tables.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
|
|
|
|
MODULE_DESCRIPTION("IP tables Hop Limit matching module");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static bool
|
|
|
|
hl_mt6(const struct sk_buff *skb, const struct net_device *in,
|
|
|
|
const struct net_device *out, const struct xt_match *match,
|
|
|
|
const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
const struct ip6t_hl_info *info = matchinfo;
|
2007-04-26 00:54:47 +00:00
|
|
|
const struct ipv6hdr *ip6h = ipv6_hdr(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (info->mode) {
|
|
|
|
case IP6T_HL_EQ:
|
2007-07-08 05:19:08 +00:00
|
|
|
return ip6h->hop_limit == info->hop_limit;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case IP6T_HL_NE:
|
2007-07-08 05:19:08 +00:00
|
|
|
return ip6h->hop_limit != info->hop_limit;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case IP6T_HL_LT:
|
2007-07-08 05:19:08 +00:00
|
|
|
return ip6h->hop_limit < info->hop_limit;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case IP6T_HL_GT:
|
2007-07-08 05:19:08 +00:00
|
|
|
return ip6h->hop_limit > info->hop_limit;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-02-09 14:24:49 +00:00
|
|
|
printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
info->mode);
|
2007-07-08 05:15:35 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-07-08 05:15:35 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static struct xt_match hl_mt6_reg __read_mostly = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.name = "hl",
|
2007-02-07 23:11:19 +00:00
|
|
|
.family = AF_INET6,
|
2007-12-05 07:24:03 +00:00
|
|
|
.match = hl_mt6,
|
2006-03-21 02:01:43 +00:00
|
|
|
.matchsize = sizeof(struct ip6t_hl_info),
|
2005-04-16 22:20:36 +00:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static int __init hl_mt6_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-12-05 07:24:03 +00:00
|
|
|
return xt_register_match(&hl_mt6_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static void __exit hl_mt6_exit(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-12-05 07:24:03 +00:00
|
|
|
xt_unregister_match(&hl_mt6_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
module_init(hl_mt6_init);
|
|
|
|
module_exit(hl_mt6_exit);
|