2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* ebt_pkttype
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Bart De Schuymer <bdschuym@pandora.be>
|
|
|
|
*
|
|
|
|
* April, 2003
|
|
|
|
*
|
|
|
|
*/
|
2008-10-08 11:35:13 +02:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/netfilter_bridge/ebtables.h>
|
|
|
|
#include <linux/netfilter_bridge/ebt_pkttype.h>
|
|
|
|
|
2008-10-08 11:35:15 +02:00
|
|
|
static bool
|
2009-07-07 20:42:08 +02:00
|
|
|
ebt_pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:18 +02:00
|
|
|
const struct ebt_pkttype_info *info = par->matchinfo;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-10-08 11:35:13 +02:00
|
|
|
return (skb->pkt_type == info->pkt_type) ^ info->invert;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2010-03-19 17:16:42 +01:00
|
|
|
static int ebt_pkttype_mt_check(const struct xt_mtchk_param *par)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:18 +02:00
|
|
|
const struct ebt_pkttype_info *info = par->matchinfo;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (info->invert != 0 && info->invert != 1)
|
2010-03-23 16:35:56 +01:00
|
|
|
return -EINVAL;
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Allow any pkt_type value */
|
2010-03-23 16:35:56 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-10-08 11:35:15 +02:00
|
|
|
static struct xt_match ebt_pkttype_mt_reg __read_mostly = {
|
|
|
|
.name = "pkttype",
|
2008-10-08 11:35:14 +02:00
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_BRIDGE,
|
2008-10-08 11:35:15 +02:00
|
|
|
.match = ebt_pkttype_mt,
|
|
|
|
.checkentry = ebt_pkttype_mt_check,
|
2010-02-15 18:16:26 +01:00
|
|
|
.matchsize = sizeof(struct ebt_pkttype_info),
|
2005-04-17 00:20:36 +02:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
static int __init ebt_pkttype_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:15 +02:00
|
|
|
return xt_register_match(&ebt_pkttype_mt_reg);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
static void __exit ebt_pkttype_fini(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:15 +02:00
|
|
|
xt_unregister_match(&ebt_pkttype_mt_reg);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
module_init(ebt_pkttype_init);
|
|
|
|
module_exit(ebt_pkttype_fini);
|
2008-01-31 13:00:30 +01:00
|
|
|
MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
|
2005-04-17 00:20:36 +02:00
|
|
|
MODULE_LICENSE("GPL");
|