linux/net/bridge/netfilter/ebt_mark_m.c
<<
>>
Prefs
   1/*
   2 *  ebt_mark_m
   3 *
   4 *      Authors:
   5 *      Bart De Schuymer <bdschuym@pandora.be>
   6 *
   7 *  July, 2002
   8 *
   9 */
  10#include <linux/module.h>
  11#include <linux/netfilter/x_tables.h>
  12#include <linux/netfilter_bridge/ebtables.h>
  13#include <linux/netfilter_bridge/ebt_mark_m.h>
  14
  15static bool
  16ebt_mark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
  17{
  18        const struct ebt_mark_m_info *info = par->matchinfo;
  19
  20        if (info->bitmask & EBT_MARK_OR)
  21                return !!(skb->mark & info->mask) ^ info->invert;
  22        return ((skb->mark & info->mask) == info->mark) ^ info->invert;
  23}
  24
  25static bool ebt_mark_mt_check(const struct xt_mtchk_param *par)
  26{
  27        const struct ebt_mark_m_info *info = par->matchinfo;
  28
  29        if (info->bitmask & ~EBT_MARK_MASK)
  30                return false;
  31        if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
  32                return false;
  33        if (!info->bitmask)
  34                return false;
  35        return true;
  36}
  37
  38static struct xt_match ebt_mark_mt_reg __read_mostly = {
  39        .name           = "mark_m",
  40        .revision       = 0,
  41        .family         = NFPROTO_BRIDGE,
  42        .match          = ebt_mark_mt,
  43        .checkentry     = ebt_mark_mt_check,
  44        .matchsize      = XT_ALIGN(sizeof(struct ebt_mark_m_info)),
  45        .me             = THIS_MODULE,
  46};
  47
  48static int __init ebt_mark_m_init(void)
  49{
  50        return xt_register_match(&ebt_mark_mt_reg);
  51}
  52
  53static void __exit ebt_mark_m_fini(void)
  54{
  55        xt_unregister_match(&ebt_mark_mt_reg);
  56}
  57
  58module_init(ebt_mark_m_init);
  59module_exit(ebt_mark_m_fini);
  60MODULE_DESCRIPTION("Ebtables: Packet mark match");
  61MODULE_LICENSE("GPL");
  62