initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / net / pkt_cls.h
blob4de3ea73ca5d1bdc6e91a1278b1bc7f2dd04039c
1 #ifndef __NET_PKT_CLS_H
2 #define __NET_PKT_CLS_H
5 #include <linux/pkt_cls.h>
7 struct rtattr;
8 struct tcmsg;
10 /* Basic packet classifier frontend definitions. */
12 struct tcf_result
14 unsigned long class;
15 u32 classid;
18 struct tcf_proto
20 /* Fast access part */
21 struct tcf_proto *next;
22 void *root;
23 int (*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
24 u32 protocol;
26 /* All the rest */
27 u32 prio;
28 u32 classid;
29 struct Qdisc *q;
30 void *data;
31 struct tcf_proto_ops *ops;
34 struct tcf_walker
36 int stop;
37 int skip;
38 int count;
39 int (*fn)(struct tcf_proto *, unsigned long node, struct tcf_walker *);
42 struct module;
44 struct tcf_proto_ops
46 struct tcf_proto_ops *next;
47 char kind[IFNAMSIZ];
49 int (*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
50 int (*init)(struct tcf_proto*);
51 void (*destroy)(struct tcf_proto*);
53 unsigned long (*get)(struct tcf_proto*, u32 handle);
54 void (*put)(struct tcf_proto*, unsigned long);
55 int (*change)(struct tcf_proto*, unsigned long, u32 handle, struct rtattr **, unsigned long *);
56 int (*delete)(struct tcf_proto*, unsigned long);
57 void (*walk)(struct tcf_proto*, struct tcf_walker *arg);
59 /* rtnetlink specific */
60 int (*dump)(struct tcf_proto*, unsigned long, struct sk_buff *skb, struct tcmsg*);
62 struct module *owner;
65 /* Main classifier routine: scans classifier chain attached
66 to this qdisc, (optionally) tests for protocol and asks
67 specific classifiers.
70 static inline int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res)
72 int err = 0;
73 u32 protocol = skb->protocol;
74 #ifdef CONFIG_NET_CLS_ACT
75 struct tcf_proto *otp = tp;
76 reclassify:
77 #endif
78 protocol = skb->protocol;
80 for ( ; tp; tp = tp->next) {
81 if ((tp->protocol == protocol ||
82 tp->protocol == __constant_htons(ETH_P_ALL)) &&
83 (err = tp->classify(skb, tp, res)) >= 0) {
84 #ifdef CONFIG_NET_CLS_ACT
85 if ( TC_ACT_RECLASSIFY == err) {
86 __u32 verd = (__u32) G_TC_VERD(skb->tc_verd);
87 tp = otp;
89 if (MAX_REC_LOOP < verd++) {
90 printk("rule prio %d protocol %02x reclassify is buggy packet dropped\n",tp->prio&0xffff, ntohs(tp->protocol));
91 return TC_ACT_SHOT;
93 skb->tc_verd = SET_TC_VERD(skb->tc_verd,verd);
94 goto reclassify;
95 } else {
96 if (skb->tc_verd)
97 skb->tc_verd = SET_TC_VERD(skb->tc_verd,0);
98 return err;
100 #else
102 return err;
103 #endif
107 return -1;
110 static inline void tcf_destroy(struct tcf_proto *tp)
112 tp->ops->destroy(tp);
113 module_put(tp->ops->owner);
114 kfree(tp);
117 extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
118 extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
119 extern int ing_filter(struct sk_buff *skb);
124 #endif