Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *  ebt_mark_m
  3  *
  4  *      Authors:
  5  *      Bart De Schuymer <bdschuym@pandora.be>
  6  *
  7  *  July, 2002
  8  *
  9  */
 10 
 11 #include <linux/netfilter_bridge/ebtables.h>
 12 #include <linux/netfilter_bridge/ebt_mark_m.h>
 13 #include <linux/module.h>
 14 
 15 static int ebt_filter_mark(const struct sk_buff *skb,
 16    const struct net_device *in, const struct net_device *out, const void *data,
 17    unsigned int datalen)
 18 {
 19         const struct ebt_mark_m_info *info = data;
 20 
 21         if (info->bitmask & EBT_MARK_OR)
 22                 return !(!!(skb->mark & info->mask) ^ info->invert);
 23         return !(((skb->mark & info->mask) == info->mark) ^ info->invert);
 24 }
 25 
 26 static int ebt_mark_check(const char *tablename, unsigned int hookmask,
 27    const struct ebt_entry *e, void *data, unsigned int datalen)
 28 {
 29         const struct ebt_mark_m_info *info = data;
 30 
 31         if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_m_info)))
 32                 return -EINVAL;
 33         if (info->bitmask & ~EBT_MARK_MASK)
 34                 return -EINVAL;
 35         if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
 36                 return -EINVAL;
 37         if (!info->bitmask)
 38                 return -EINVAL;
 39         return 0;
 40 }
 41 
 42 static struct ebt_match filter_mark __read_mostly = {
 43         .name           = EBT_MARK_MATCH,
 44         .match          = ebt_filter_mark,
 45         .check          = ebt_mark_check,
 46         .me             = THIS_MODULE,
 47 };
 48 
 49 static int __init ebt_mark_m_init(void)
 50 {
 51         return ebt_register_match(&filter_mark);
 52 }
 53 
 54 static void __exit ebt_mark_m_fini(void)
 55 {
 56         ebt_unregister_match(&filter_mark);
 57 }
 58 
 59 module_init(ebt_mark_m_init);
 60 module_exit(ebt_mark_m_fini);
 61 MODULE_DESCRIPTION("Ebtables: Packet mark match");
 62 MODULE_LICENSE("GPL");
 63 
  This page was automatically generated by the LXR engine.