25 #include <netlink-private/netlink.h>
26 #include <netlink-private/tc.h>
27 #include <netlink/netlink.h>
28 #include <netlink-private/route/tc-api.h>
29 #include <netlink/route/classifier.h>
30 #include <netlink/route/cls/basic.h>
31 #include <netlink/route/cls/ematch.h>
36 struct rtnl_ematch_tree * b_ematch;
41 #define BASIC_ATTR_TARGET 0x001
42 #define BASIC_ATTR_EMATCH 0x002
45 static struct nla_policy basic_policy[TCA_BASIC_MAX+1] = {
50 static int basic_clone(
void *_dst,
void *_src)
52 return -NLE_OPNOTSUPP;
55 static void basic_free_data(
struct rtnl_tc *tc,
void *data)
65 static int basic_msg_parser(
struct rtnl_tc *tc,
void *data)
67 struct nlattr *tb[TCA_BASIC_MAX + 1];
71 err = tca_parse(tb, TCA_BASIC_MAX, tc, basic_policy);
75 if (tb[TCA_BASIC_CLASSID]) {
77 b->b_mask |= BASIC_ATTR_TARGET;
80 if (tb[TCA_BASIC_EMATCHES]) {
86 b->b_mask |= BASIC_ATTR_EMATCH;
92 static void basic_dump_line(
struct rtnl_tc *tc,
void *data,
101 if (b->b_mask & BASIC_ATTR_EMATCH)
106 if (b->b_mask & BASIC_ATTR_TARGET)
111 static void basic_dump_details(
struct rtnl_tc *tc,
void *data,
119 if (b->b_mask & BASIC_ATTR_EMATCH) {
120 nl_dump_line(p,
" ematch ");
121 rtnl_ematch_tree_dump(b->b_ematch, p);
126 static int basic_msg_fill(
struct rtnl_tc *tc,
void *data,
134 if (!(b->b_mask & BASIC_ATTR_TARGET))
135 return -NLE_MISSING_ATTR;
139 if (b->b_mask & BASIC_ATTR_EMATCH &&
140 rtnl_ematch_fill_attr(msg, TCA_BASIC_EMATCHES, b->b_ematch) < 0)
141 goto nla_put_failure;
154 void rtnl_basic_set_target(
struct rtnl_cls *cls, uint32_t target)
161 b->b_target = target;
162 b->b_mask |= BASIC_ATTR_TARGET;
165 uint32_t rtnl_basic_get_target(
struct rtnl_cls *cls)
175 void rtnl_basic_set_ematch(
struct rtnl_cls *cls,
struct rtnl_ematch_tree *tree)
184 b->b_mask &= ~BASIC_ATTR_EMATCH;
190 b->b_mask |= BASIC_ATTR_EMATCH;
193 struct rtnl_ematch_tree *rtnl_basic_get_ematch(
struct rtnl_cls *cls)
205 static struct rtnl_tc_ops basic_ops = {
207 .to_type = RTNL_TC_TYPE_CLS,
209 .to_msg_parser = basic_msg_parser,
210 .to_clone = basic_clone,
211 .to_free_data = basic_free_data,
212 .to_msg_fill = basic_msg_fill,
219 static void __init basic_init(
void)
224 static void __exit basic_exit(
void)