2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ebt_mark_m
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Bart De Schuymer <bdschuym@pandora.be>
|
|
|
|
*
|
|
|
|
* July, 2002
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netfilter_bridge/ebtables.h>
|
|
|
|
#include <linux/netfilter_bridge/ebt_mark_m.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
static int ebt_filter_mark(const struct sk_buff *skb,
|
|
|
|
const struct net_device *in, const struct net_device *out, const void *data,
|
|
|
|
unsigned int datalen)
|
|
|
|
{
|
2008-01-31 11:59:24 +00:00
|
|
|
const struct ebt_mark_m_info *info = data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (info->bitmask & EBT_MARK_OR)
|
2006-11-09 23:19:14 +00:00
|
|
|
return !(!!(skb->mark & info->mask) ^ info->invert);
|
|
|
|
return !(((skb->mark & info->mask) == info->mark) ^ info->invert);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ebt_mark_check(const char *tablename, unsigned int hookmask,
|
|
|
|
const struct ebt_entry *e, void *data, unsigned int datalen)
|
|
|
|
{
|
2008-01-31 11:59:24 +00:00
|
|
|
const struct ebt_mark_m_info *info = data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_m_info)))
|
|
|
|
return -EINVAL;
|
|
|
|
if (info->bitmask & ~EBT_MARK_MASK)
|
|
|
|
return -EINVAL;
|
|
|
|
if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
|
|
|
|
return -EINVAL;
|
|
|
|
if (!info->bitmask)
|
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ebt_match filter_mark =
|
|
|
|
{
|
|
|
|
.name = EBT_MARK_MATCH,
|
|
|
|
.match = ebt_filter_mark,
|
|
|
|
.check = ebt_mark_check,
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static int __init ebt_mark_m_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return ebt_register_match(&filter_mark);
|
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static void __exit ebt_mark_m_fini(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
ebt_unregister_match(&filter_mark);
|
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
module_init(ebt_mark_m_init);
|
|
|
|
module_exit(ebt_mark_m_fini);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|