TCA_CANPRIO_A_UNSPEC,
TCA_CANPRIO_CLASSID,
TCA_CANPRIO_MATCH,
- TCA_CANPRIO_XY,
+ TCA_CANPRIO_MATCH_MASK,
__TCA_CANPRIO_MAX,
};
#define TCA_CANPRIO_MAX (__TCA_CANPRIO_MAX - 1)
static const struct nla_policy canprio_policy[TCA_CANPRIO_MAX + 1] = {
- [TCA_CANPRIO_CLASSID] = { .type = NLA_U32 },
- [TCA_CANPRIO_MATCH] = { .type = NLA_U32 }, //{ .type = NLA_NESTED },
- [TCA_CANPRIO_XY] = { .type = NLA_U32 },
+ [TCA_CANPRIO_CLASSID] = { .type = NLA_U32 },
+ [TCA_CANPRIO_MATCH] = { .type = NLA_U32 }, //{ .type = NLA_NESTED },
+ [TCA_CANPRIO_MATCH_MASK] = { .type = NLA_U32 },
};
struct canprio_head {
struct canprio_filter {
u32 handle;
- u32 match; // Matching CAN ID. Will be sth like list os lists
+ u32 canid;
+ u32 canid_mask;
struct tcf_result res;
struct list_head link;
};
struct canprio_head *head = (struct canprio_head *)tp->root;
struct canprio_filter *f;
- printk(" canprio_classify invoked\n");
+ printk(" canprio_classify() invoked\n");
list_for_each_entry(f, &head->flist, link) {
- printk(" canprio_classify can ID = 0x%x\n", canprio_get_id(skb));
- if (canprio_get_id(skb) == f->match) {
- printk( " canprio_classify match ID 0x%x\n", f->match);
+ printk(" canprio_classify() can ID of received frame = 0x%x\n", canprio_get_id(skb));
+ if ((canprio_get_id(skb) & f->canid_mask) == (f->canid & f->canid_mask)) {
+ printk( " canprio_classify() match ok: ID 0x%x mask 0x%x\n",
+ f->canid, f->canid_mask);
*res = f->res;
return TC_POLICE_OK;
}
struct nlattr *est)
{
//int err;
+ printk(" canprio_set_parms invoked\n");
if (tb[TCA_CANPRIO_CLASSID]) {
f->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);
if (tca[TCA_OPTIONS] == NULL)
return -EINVAL;
+ //Parses a stream of attributes and stores a pointer to each attribute in
+ //the tb array accessible via the attribute type. Policy may be set to NULL
+ //if no validation is required.
err = nla_parse_nested(tb, TCA_CANPRIO_MAX, tca[TCA_OPTIONS], canprio_policy);
if (err < 0)
return err;
return -EINVAL;
//f->match = nla_data(tb[TCA_CANPRIO_MATCH]);
- f->match = nla_get_u32(tb[TCA_CANPRIO_MATCH]);
- printk(" can ID to match = 0x%x\n", f->match);
+ f->canid = nla_get_u32(tb[TCA_CANPRIO_MATCH]);
+ f->canid_mask = nla_get_u32(tb[TCA_CANPRIO_MATCH_MASK]);
+ printk(" can ID to match = 0x%x with mask 0x%x\n", f->canid, f->canid_mask);
//Add newly created filter to list of all filters
tcf_tree_lock(tp);