#define TCA_ATTR_MPU 0x0800
#define TCA_ATTR_OVERHEAD 0x1000
#define TCA_ATTR_LINKTYPE 0x2000
-#define TCA_ATTR_MAX TCA_ATTR_LINKTYPE
+#define TCA_ATTR_CHAIN 0x4000
+#define TCA_ATTR_MAX TCA_ATTR_CHAIN
extern int tca_parse(struct nlattr **, int, struct rtnl_tc *,
const struct nla_policy *);
extern int rtnl_tc_str2handle(const char *, uint32_t *);
extern int rtnl_classid_generate(const char *, uint32_t *,
uint32_t);
+extern void rtnl_tc_set_chain(struct rtnl_tc *, uint32_t);
+extern uint32_t rtnl_tc_get_chain(struct rtnl_tc *);
#ifdef __cplusplus
}
static struct nla_policy tc_policy[TCA_MAX+1] = {
[TCA_KIND] = { .type = NLA_STRING,
.maxlen = TCKINDSIZ },
+ [TCA_CHAIN] = { .type = NLA_U32 },
[TCA_STATS] = { .minlen = sizeof(struct tc_stats) },
[TCA_STATS2] = { .type = NLA_NESTED },
};
nla_strlcpy(kind, tb[TCA_KIND], sizeof(kind));
rtnl_tc_set_kind(tc, kind);
+ if (tb[TCA_CHAIN])
+ rtnl_tc_set_chain(tc, nla_get_u32(tb[TCA_CHAIN]));
+
tm = nlmsg_data(n);
tc->tc_family = tm->tcm_family;
tc->tc_ifindex = tm->tcm_ifindex;
if (tc->ce_mask & TCA_ATTR_KIND)
NLA_PUT_STRING(msg, TCA_KIND, tc->tc_kind);
+ if (tc->ce_mask & TCA_ATTR_CHAIN)
+ NLA_PUT_U32(msg, TCA_CHAIN, tc->tc_chain);
+
ops = rtnl_tc_get_ops(tc);
if (ops && (ops->to_msg_fill || ops->to_msg_fill_raw)) {
struct nlattr *opts;
return tc->tc_stats[id];
}
+/**
+ * Set the chain index of a traffic control object
+ * @arg tc traffic control object
+ * @arg chain chain index of traffic control object
+ *
+ */
+void rtnl_tc_set_chain(struct rtnl_tc *tc, uint32_t chain)
+{
+ tc->tc_chain = chain;
+ tc->ce_mask |= TCA_ATTR_CHAIN;
+}
+
+/**
+ * Return chain index of traffic control object
+ * @arg tc traffic control object
+ *
+ * @return chain index of traffic control object or 0 if not set.
+ */
+uint32_t rtnl_tc_get_chain(struct rtnl_tc *tc)
+{
+ if (tc->ce_mask & TCA_ATTR_CHAIN)
+ return tc->tc_chain;
+ else
+ return 0;
+}
+
/** @} */
/**