2 * Copyright (c) 2003-2013 Patrick McHardy <kaber@trash.net>
7 #include <linux/netfilter/xt_CLASSIFY.h>
8 #include <linux/pkt_sched.h>
18 "CLASSIFY target options:\n"
19 "--set-class MAJOR:MINOR Set skb->priority value (always hexadecimal!)\n");
22 static const struct xt_option_entry CLASSIFY_opts[] = {
23 {.name = "set-class", .id = O_SET_CLASS, .type = XTTYPE_STRING,
28 static int CLASSIFY_string_to_priority(const char *s, unsigned int *p)
32 if (sscanf(s, "%x:%x", &i, &j) != 2)
35 *p = TC_H_MAKE(i<<16, j);
39 static void CLASSIFY_parse(struct xt_option_call *cb)
41 struct xt_classify_target_info *clinfo = cb->data;
43 xtables_option_parse(cb);
44 if (CLASSIFY_string_to_priority(cb->arg, &clinfo->priority))
45 xtables_error(PARAMETER_PROBLEM,
46 "Bad class value \"%s\"", cb->arg);
50 CLASSIFY_print_class(unsigned int priority, int numeric)
52 printf(" %x:%x", TC_H_MAJ(priority)>>16, TC_H_MIN(priority));
56 CLASSIFY_print(const void *ip,
57 const struct xt_entry_target *target,
60 const struct xt_classify_target_info *clinfo =
61 (const struct xt_classify_target_info *)target->data;
62 printf(" CLASSIFY set");
63 CLASSIFY_print_class(clinfo->priority, numeric);
67 CLASSIFY_save(const void *ip, const struct xt_entry_target *target)
69 const struct xt_classify_target_info *clinfo =
70 (const struct xt_classify_target_info *)target->data;
72 printf(" --set-class %.4x:%.4x",
73 TC_H_MAJ(clinfo->priority)>>16, TC_H_MIN(clinfo->priority));
76 static struct xtables_target classify_target = {
77 .family = NFPROTO_UNSPEC,
79 .version = XTABLES_VERSION,
80 .size = XT_ALIGN(sizeof(struct xt_classify_target_info)),
81 .userspacesize = XT_ALIGN(sizeof(struct xt_classify_target_info)),
82 .help = CLASSIFY_help,
83 .print = CLASSIFY_print,
84 .save = CLASSIFY_save,
85 .x6_parse = CLASSIFY_parse,
86 .x6_options = CLASSIFY_opts,
91 xtables_register_target(&classify_target);