13#include <netlink-private/netlink.h>
14#include <netlink-private/tc.h>
15#include <netlink/netlink.h>
16#include <netlink/attr.h>
17#include <netlink/utils.h>
18#include <netlink-private/route/tc-api.h>
19#include <netlink/route/act/gact.h>
21static struct nla_policy gact_policy[TCA_GACT_MAX + 1] = {
22 [TCA_GACT_PARMS] = { .
minlen =
sizeof(
struct tc_gact) },
25static int gact_msg_parser(
struct rtnl_tc *tc,
void *data)
27 struct rtnl_gact *u = data;
28 struct nlattr *tb[TCA_GACT_MAX + 1];
31 err = tca_parse(tb, TCA_GACT_MAX, tc, gact_policy);
35 if (!tb[TCA_GACT_PARMS])
36 return -NLE_MISSING_ATTR;
38 nla_memcpy(&u->g_parm, tb[TCA_GACT_PARMS],
sizeof(u->g_parm));
43static void gact_free_data(
struct rtnl_tc *tc,
void *data)
47static void gact_dump_line(
struct rtnl_tc *tc,
void *data,
50 struct rtnl_gact *u = data;
55 switch(u->g_parm.action){
62 case TC_ACT_RECLASSIFY:
72static void gact_dump_details(
struct rtnl_tc *tc,
void *data,
77static void gact_dump_stats(
struct rtnl_tc *tc,
void *data,
80 struct rtnl_gact *u = data;
88static int gact_msg_fill(
struct rtnl_tc *tc,
void *data,
struct nl_msg *msg)
90 struct rtnl_gact *u = data;
95 NLA_PUT(msg, TCA_GACT_PARMS,
sizeof(u->g_parm), &u->g_parm);
108int rtnl_gact_set_action(
struct rtnl_act *act,
int action)
115 u->g_parm.action = action;
120int rtnl_gact_get_action(
struct rtnl_act *act)
126 return u->g_parm.action;
132static struct rtnl_tc_ops gact_ops = {
134 .to_type = RTNL_TC_TYPE_ACT,
135 .to_size =
sizeof(
struct rtnl_gact),
136 .to_msg_parser = gact_msg_parser,
137 .to_free_data = gact_free_data,
139 .to_msg_fill = gact_msg_fill,
147static void __init gact_init(
void)
152static void __exit gact_exit(
void)
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
#define TC_CAST(ptr)
Macro to cast qdisc/class/classifier to tc object.
void * rtnl_tc_data(struct rtnl_tc *tc)
Return pointer to private data of traffic control object.
int rtnl_tc_register(struct rtnl_tc_ops *ops)
Register a traffic control module.
void rtnl_tc_unregister(struct rtnl_tc_ops *ops)
Unregister a traffic control module.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
@ NL_DUMP_STATS
Dump all attributes including statistics.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.
uint16_t minlen
Minimal length of payload required.