#include "utils.h"
#include "tc_util.h"
+struct canprio_rule {
+ __u32 canid;
+ __u32 canid_mask;
+};
+
+struct canprio_rule canprio_rules[32];
static void explain(void)
{
struct rtattr *tail;
long h = 0;
__u32 canid, canid_mask;
-
+ int rules_count = 0;
if (argc == 0)
return 0;
//printf("... 0x%x:0x%x]\n", canid, canid_mask);
if (canid > 0) {// FIXME boundary check
- addattr32(n, 4096, TCA_CANPRIO_MATCH, canid);
- addattr32(n, 4096, TCA_CANPRIO_MATCH_MASK, canid_mask);
+ canprio_rules[rules_count].canid = canid;
+ canprio_rules[rules_count].canid_mask = canid_mask;
+ rules_count++;
}
} else if (matches(*argv, "classid") == 0 ||
argc--; argv++;
}
-
+
+ addattr_l(n, MAX_MSG, TCA_CANPRIO_RULES, &canprio_rules,
+ sizeof(struct canprio_rule) * rules_count);
tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
return 0;
sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
}
- if (tb[TCA_CANPRIO_MATCH])
- fprintf(f, "Canid 0x%x ",
- *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH]));
- if (tb[TCA_CANPRIO_MATCH_MASK])
- fprintf(f, "Canid mask %x ",
- *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH_MASK]));
+ //FIXME
+ //if (tb[TCA_CANPRIO_RULES])
+ // fprintf(f, "Canid 0x%x ",
+ // *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH]));
return 0;
else # create Prio qdiscs and configure canprio filter
sudo ./tc qdisc add dev can0 root handle 1: prio
- sudo ./tc filter add dev can0 parent 1:0 prio 1 canprio match 0x123:0xffff flowid 1:1
+ sudo ./tc filter add dev can0 parent 1:0 prio 1 canprio match 0x123:0xffff match 0x124:0xffff flowid 1:1
sudo ./tc filter add dev can0 parent 1:0 prio 2 canprio match 0x223:0xffff flowid 1:2
- sudo ./tc filter add dev can0 parent 1:0 prio 3 canprio match 0x323:0xffff flowid 1:3
+ sudo ./tc filter add dev can0 parent 1:0 prio 3 canprio match 0x1:0x1 flowid 1:3
sudo ./tc qdisc show dev can0