Blame view

net/netfilter/xt_CLASSIFY.c 1.96 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  /*
   * This is a module which is used for setting the skb->priority field
   * of an skb for qdisc classification.
   */
  
  /* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #include <linux/module.h>
  #include <linux/skbuff.h>
  #include <linux/ip.h>
  #include <net/checksum.h>
891350c9d   Patrick McHardy   [NETFILTER]: xt_m...
17
18
  #include <linux/netfilter_ipv4.h>
  #include <linux/netfilter_ipv6.h>
2e4e6a17a   Harald Welte   [NETFILTER] x_tab...
19
20
  #include <linux/netfilter/x_tables.h>
  #include <linux/netfilter/xt_CLASSIFY.h>
9811600f7   Frédéric Leroy   netfilter: xt_CLA...
21
  #include <linux/netfilter_arp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
  
  MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  MODULE_LICENSE("GPL");
2ae15b64e   Jan Engelhardt   [NETFILTER]: Upda...
25
  MODULE_DESCRIPTION("Xtables: Qdisc classification");
2e4e6a17a   Harald Welte   [NETFILTER] x_tab...
26
  MODULE_ALIAS("ipt_CLASSIFY");
73aaf9355   Jan Engelhardt   [NETFILTER]: x_ta...
27
  MODULE_ALIAS("ip6t_CLASSIFY");
9811600f7   Frédéric Leroy   netfilter: xt_CLA...
28
  MODULE_ALIAS("arpt_CLASSIFY");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
  
  static unsigned int
4b560b447   Jan Engelhardt   netfilter: xtable...
31
  classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  {
7eb355865   Jan Engelhardt   netfilter: xtable...
33
  	const struct xt_classify_target_info *clinfo = par->targinfo;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34

3db05fea5   Herbert Xu   [NETFILTER]: Repl...
35
  	skb->priority = clinfo->priority;
2e4e6a17a   Harald Welte   [NETFILTER] x_tab...
36
  	return XT_CONTINUE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  }
9811600f7   Frédéric Leroy   netfilter: xt_CLA...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  static struct xt_target classify_tg_reg[] __read_mostly = {
  	{
  		.name       = "CLASSIFY",
  		.revision   = 0,
  		.family     = NFPROTO_UNSPEC,
  		.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
  		              (1 << NF_INET_POST_ROUTING),
  		.target     = classify_tg,
  		.targetsize = sizeof(struct xt_classify_target_info),
  		.me         = THIS_MODULE,
  	},
  	{
  		.name       = "CLASSIFY",
  		.revision   = 0,
  		.family     = NFPROTO_ARP,
  		.hooks      = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
  		.target     = classify_tg,
  		.targetsize = sizeof(struct xt_classify_target_info),
  		.me         = THIS_MODULE,
  	},
2e4e6a17a   Harald Welte   [NETFILTER] x_tab...
58
  };
2e4e6a17a   Harald Welte   [NETFILTER] x_tab...
59

d3c5ee6d5   Jan Engelhardt   [NETFILTER]: x_ta...
60
  static int __init classify_tg_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
  {
9811600f7   Frédéric Leroy   netfilter: xt_CLA...
62
  	return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
  }
d3c5ee6d5   Jan Engelhardt   [NETFILTER]: x_ta...
64
  static void __exit classify_tg_exit(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65
  {
9811600f7   Frédéric Leroy   netfilter: xt_CLA...
66
  	xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
  }
d3c5ee6d5   Jan Engelhardt   [NETFILTER]: x_ta...
68
69
  module_init(classify_tg_init);
  module_exit(classify_tg_exit);