xt_CLASSIFY.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <linux/netfilter_arp.h>
  20. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  21. MODULE_LICENSE("GPL");
  22. MODULE_DESCRIPTION("Xtables: Qdisc classification");
  23. MODULE_ALIAS("ipt_CLASSIFY");
  24. MODULE_ALIAS("ip6t_CLASSIFY");
  25. MODULE_ALIAS("arpt_CLASSIFY");
  26. static unsigned int
  27. classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
  28. {
  29. const struct xt_classify_target_info *clinfo = par->targinfo;
  30. skb->priority = clinfo->priority;
  31. return XT_CONTINUE;
  32. }
  33. static struct xt_target classify_tg_reg[] __read_mostly = {
  34. {
  35. .name = "CLASSIFY",
  36. .revision = 0,
  37. .family = NFPROTO_UNSPEC,
  38. .hooks = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
  39. (1 << NF_INET_POST_ROUTING),
  40. .target = classify_tg,
  41. .targetsize = sizeof(struct xt_classify_target_info),
  42. .me = THIS_MODULE,
  43. },
  44. {
  45. .name = "CLASSIFY",
  46. .revision = 0,
  47. .family = NFPROTO_ARP,
  48. .hooks = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
  49. .target = classify_tg,
  50. .targetsize = sizeof(struct xt_classify_target_info),
  51. .me = THIS_MODULE,
  52. },
  53. };
  54. static int __init classify_tg_init(void)
  55. {
  56. return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
  57. }
  58. static void __exit classify_tg_exit(void)
  59. {
  60. xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
  61. }
  62. module_init(classify_tg_init);
  63. module_exit(classify_tg_exit);