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