2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* 802_3
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Chris Vitale csv@bluetail.com
|
|
|
|
*
|
|
|
|
* May 2003
|
2007-02-09 15:24:35 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
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_802_3.h>
|
|
|
|
|
2008-10-08 11:35:15 +02:00
|
|
|
static bool
|
2009-07-07 20:42:08 +02:00
|
|
|
ebt_802_3_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_802_3_info *info = par->matchinfo;
|
2008-01-31 12:59:24 +01:00
|
|
|
const struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
|
2006-11-15 06:11:51 +01:00
|
|
|
__be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (info->bitmask & EBT_802_3_SAP) {
|
2007-02-09 15:24:35 +01:00
|
|
|
if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP))
|
2008-10-08 11:35:13 +02:00
|
|
|
return false;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
|
2008-10-08 11:35:13 +02:00
|
|
|
return false;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (info->bitmask & EBT_802_3_TYPE) {
|
|
|
|
if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
|
2008-10-08 11:35:13 +02:00
|
|
|
return false;
|
2007-02-09 15:24:35 +01:00
|
|
|
if (FWINV(info->type != type, EBT_802_3_TYPE))
|
2008-10-08 11:35:13 +02:00
|
|
|
return false;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-10-08 11:35:13 +02:00
|
|
|
return true;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2010-03-19 17:16:42 +01:00
|
|
|
static int ebt_802_3_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_802_3_info *info = par->matchinfo;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
|
2010-03-23 16:35:56 +01:00
|
|
|
return -EINVAL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
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_802_3_mt_reg __read_mostly = {
|
|
|
|
.name = "802_3",
|
2008-10-08 11:35:14 +02:00
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_BRIDGE,
|
2008-10-08 11:35:15 +02:00
|
|
|
.match = ebt_802_3_mt,
|
|
|
|
.checkentry = ebt_802_3_mt_check,
|
2010-02-15 18:16:26 +01:00
|
|
|
.matchsize = sizeof(struct ebt_802_3_info),
|
2005-04-17 00:20:36 +02:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
static int __init ebt_802_3_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:15 +02:00
|
|
|
return xt_register_match(&ebt_802_3_mt_reg);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
static void __exit ebt_802_3_fini(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-10-08 11:35:15 +02:00
|
|
|
xt_unregister_match(&ebt_802_3_mt_reg);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-29 02:37:06 +02:00
|
|
|
module_init(ebt_802_3_init);
|
|
|
|
module_exit(ebt_802_3_fini);
|
2008-01-31 13:00:30 +01:00
|
|
|
MODULE_DESCRIPTION("Ebtables: DSAP/SSAP field and SNAP type matching");
|
2005-04-17 00:20:36 +02:00
|
|
|
MODULE_LICENSE("GPL");
|