xt_CLASSIFY.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This is a module which is used for setting the skb->priority field
  3. * of an skb for qdisc classification.
  4. */
  5. /* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/skbuff.h>
  13. #include <linux/ip.h>
  14. #include <net/checksum.h>
  15. #include <linux/netfilter_ipv4.h>
  16. #include <linux/netfilter_ipv6.h>
  17. #include <linux/netfilter/x_tables.h>
  18. #include <linux/netfilter/xt_CLASSIFY.h>
  19. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  20. MODULE_LICENSE("GPL");
  21. MODULE_DESCRIPTION("iptables qdisc classification target module");
  22. MODULE_ALIAS("ipt_CLASSIFY");
  23. static unsigned int
  24. target(struct sk_buff **pskb,
  25. const struct net_device *in,
  26. const struct net_device *out,
  27. unsigned int hooknum,
  28. const struct xt_target *target,
  29. const void *targinfo)
  30. {
  31. const struct xt_classify_target_info *clinfo = targinfo;
  32. (*pskb)->priority = clinfo->priority;
  33. return XT_CONTINUE;
  34. }
  35. static struct xt_target xt_classify_target[] = {
  36. {
  37. .family = AF_INET,
  38. .name = "CLASSIFY",
  39. .target = target,
  40. .targetsize = sizeof(struct xt_classify_target_info),
  41. .table = "mangle",
  42. .hooks = (1 << NF_IP_LOCAL_OUT) |
  43. (1 << NF_IP_FORWARD) |
  44. (1 << NF_IP_POST_ROUTING),
  45. .me = THIS_MODULE,
  46. },
  47. {
  48. .name = "CLASSIFY",
  49. .family = AF_INET6,
  50. .target = target,
  51. .targetsize = sizeof(struct xt_classify_target_info),
  52. .table = "mangle",
  53. .hooks = (1 << NF_IP6_LOCAL_OUT) |
  54. (1 << NF_IP6_FORWARD) |
  55. (1 << NF_IP6_POST_ROUTING),
  56. .me = THIS_MODULE,
  57. },
  58. };
  59. static int __init xt_classify_init(void)
  60. {
  61. return xt_register_targets(xt_classify_target,
  62. ARRAY_SIZE(xt_classify_target));
  63. }
  64. static void __exit xt_classify_fini(void)
  65. {
  66. xt_unregister_targets(xt_classify_target,
  67. ARRAY_SIZE(xt_classify_target));
  68. }
  69. module_init(xt_classify_init);
  70. module_exit(xt_classify_fini);