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 /* Hop Limit matching module */
  2 
  3 /* (C) 2001-2002 Maciej Soltysiak <solt@dns.toxicfilms.tv>
  4  * Based on HW's ttl module
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License version 2 as
  8  * published by the Free Software Foundation.
  9  */
 10 
 11 #include <linux/ipv6.h>
 12 #include <linux/module.h>
 13 #include <linux/skbuff.h>
 14 
 15 #include <linux/netfilter_ipv6/ip6t_hl.h>
 16 #include <linux/netfilter/x_tables.h>
 17 
 18 MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
 19 MODULE_DESCRIPTION("Xtables: IPv6 Hop Limit field match");
 20 MODULE_LICENSE("GPL");
 21 
 22 static bool
 23 hl_mt6(const struct sk_buff *skb, const struct net_device *in,
 24        const struct net_device *out, const struct xt_match *match,
 25        const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
 26 {
 27         const struct ip6t_hl_info *info = matchinfo;
 28         const struct ipv6hdr *ip6h = ipv6_hdr(skb);
 29 
 30         switch (info->mode) {
 31                 case IP6T_HL_EQ:
 32                         return ip6h->hop_limit == info->hop_limit;
 33                         break;
 34                 case IP6T_HL_NE:
 35                         return ip6h->hop_limit != info->hop_limit;
 36                         break;
 37                 case IP6T_HL_LT:
 38                         return ip6h->hop_limit < info->hop_limit;
 39                         break;
 40                 case IP6T_HL_GT:
 41                         return ip6h->hop_limit > info->hop_limit;
 42                         break;
 43                 default:
 44                         printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
 45                                 info->mode);
 46                         return false;
 47         }
 48 
 49         return false;
 50 }
 51 
 52 static struct xt_match hl_mt6_reg __read_mostly = {
 53         .name           = "hl",
 54         .family         = AF_INET6,
 55         .match          = hl_mt6,
 56         .matchsize      = sizeof(struct ip6t_hl_info),
 57         .me             = THIS_MODULE,
 58 };
 59 
 60 static int __init hl_mt6_init(void)
 61 {
 62         return xt_register_match(&hl_mt6_reg);
 63 }
 64 
 65 static void __exit hl_mt6_exit(void)
 66 {
 67         xt_unregister_match(&hl_mt6_reg);
 68 }
 69 
 70 module_init(hl_mt6_init);
 71 module_exit(hl_mt6_exit);
 72 
  This page was automatically generated by the LXR engine.