blob: af9c4dadf8165922af9ee23b02abc48047496a87 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This is a module which is used for setting the skb->priority field
3 * of an skb for qdisc classification.
4 */
5
6/* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/skbuff.h>
15#include <linux/ip.h>
16#include <net/checksum.h>
17
Patrick McHardy891350c2007-02-12 11:14:43 -080018#include <linux/netfilter_ipv4.h>
19#include <linux/netfilter_ipv6.h>
Harald Welte2e4e6a12006-01-12 13:30:04 -080020#include <linux/netfilter/x_tables.h>
21#include <linux/netfilter/xt_CLASSIFY.h>
Frédéric Leroy98116002010-11-15 13:57:56 +010022#include <linux/netfilter_arp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
25MODULE_LICENSE("GPL");
Jan Engelhardt2ae15b62008-01-14 23:42:28 -080026MODULE_DESCRIPTION("Xtables: Qdisc classification");
Harald Welte2e4e6a12006-01-12 13:30:04 -080027MODULE_ALIAS("ipt_CLASSIFY");
Jan Engelhardt73aaf932007-10-11 14:36:40 -070028MODULE_ALIAS("ip6t_CLASSIFY");
Frédéric Leroy98116002010-11-15 13:57:56 +010029MODULE_ALIAS("arpt_CLASSIFY");
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31static unsigned int
Jan Engelhardt4b560b42009-07-05 19:43:26 +020032classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Jan Engelhardt7eb35582008-10-08 11:35:19 +020034 const struct xt_classify_target_info *clinfo = par->targinfo;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Herbert Xu3db05fe2007-10-15 00:53:15 -070036 skb->priority = clinfo->priority;
Harald Welte2e4e6a12006-01-12 13:30:04 -080037 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
Frédéric Leroy98116002010-11-15 13:57:56 +010040static struct xt_target classify_tg_reg[] __read_mostly = {
41 {
42 .name = "CLASSIFY",
43 .revision = 0,
44 .family = NFPROTO_UNSPEC,
45 .hooks = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
46 (1 << NF_INET_POST_ROUTING),
47 .target = classify_tg,
48 .targetsize = sizeof(struct xt_classify_target_info),
49 .me = THIS_MODULE,
50 },
51 {
52 .name = "CLASSIFY",
53 .revision = 0,
54 .family = NFPROTO_ARP,
55 .hooks = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
56 .target = classify_tg,
57 .targetsize = sizeof(struct xt_classify_target_info),
58 .me = THIS_MODULE,
59 },
Harald Welte2e4e6a12006-01-12 13:30:04 -080060};
Harald Welte2e4e6a12006-01-12 13:30:04 -080061
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080062static int __init classify_tg_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Frédéric Leroy98116002010-11-15 13:57:56 +010064 return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080067static void __exit classify_tg_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Frédéric Leroy98116002010-11-15 13:57:56 +010069 xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080072module_init(classify_tg_init);
73module_exit(classify_tg_exit);