* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * FIXME add patch made by Oliver
+ * Idea: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Copyright: (c) 2011 Czech Technical University in Prague
+ * (c) 2011 Volkswagen Group Research
* Authors: Michal Sojka <sojkam1@fel.cvut.cz>
* Pavel Pisa <pisa@cmp.felk.cvut.cz>
* Rostislav Lisovy <lisovy@kormus.cz>
+ * Founded by: Volkswagen Group Research
*/
#include <stdio.h>
addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
while (argc > 0) {
+//---------------------- legacy option; will be deleted in future -------------
if (matches(*argv, "match") == 0) {
- //printf(" [parsing match ...");
NEXT_ARG();
if (sscanf(*argv, "%"SCNx32 ":" "%"SCNx32, &can_id, &can_mask) != 2) {
canprio_rules[rules_count].can_mask = can_mask;
rules_count++;
}
+//---------------------- legacy option; will be deleted in future -------------
- } else if (matches(*argv, "matchid") == 0) {
+ } else if (matches(*argv, "matchid") == 0) { //Parse SFF ID
NEXT_ARG();
if (sscanf(*argv, "%"SCNx32 ":" "%"SCNx32, &can_id, &can_mask) != 2) {
return -1;
}
- if (can_id & ~CAN_SFF_MASK) {
- fprintf(stderr, "Id 0x%lx exceeded standard CAN ID range.\n",
+ if (can_id & ~CAN_SFF_MASK) { //FIXME what about RTR flags?
+ fprintf(stderr, "ID 0x%lx exceeded standard CAN ID range.\n",
(unsigned long)can_id);
return -1;
}
canprio_rules[rules_count].can_mask = (can_mask & CAN_SFF_MASK);
rules_count++;
- } else if (matches(*argv, "matcheid") == 0) {
+ } else if (matches(*argv, "matcheid") == 0) { //Parse EFF ID
NEXT_ARG();
if (sscanf(*argv, "%"SCNx32 ":" "%"SCNx32, &can_id, &can_mask) != 2) {
}
if (can_id & ~CAN_EFF_MASK) {
- fprintf(stderr, "Id 0x%lx exceeded extended CAN ID range.",
+ fprintf(stderr, "ID 0x%lx exceeded extended CAN ID range.",
(unsigned long)can_id);
return -1;
}
canprio_rules[rules_count].can_id = can_id | CAN_EFF_FLAG;
- canprio_rules[rules_count].can_mask = (can_mask & CAN_EFF_MASK);
+ canprio_rules[rules_count].can_mask =
+ (can_mask & CAN_EFF_MASK) | CAN_EFF_FLAG;
rules_count++;
} else if (matches(*argv, "classid") == 0 ||
}
/* When "tc filter show dev XY" is executed, function canprio_walk() (in kernel)
-is called (which calls canprio_dump() for each instance of a filter) which sends
-information about each instance of a filters to userspace -- to this function
-(which parses the message and prints it. */
+ * is called (which calls canprio_dump() for each instance of a filter) which sends
+ * information about each instance of a filters to userspace -- to this function
+ * (which parses the message and prints it.
+ */
static int canprio_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
__u32 handle)
{
sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
}
-/* if (tb[TCA_CANPRIO_RULES]) {
+ if (tb[TCA_CANPRIO_RULES]) {
if (RTA_PAYLOAD(tb[TCA_CANPRIO_RULES]) < sizeof(struct can_filter))
return -1;
canprio_rules = RTA_DATA(tb[TCA_CANPRIO_RULES]);
- rules_count = RTA_PAYLOAD(tb[TCA_CANPRIO_RULES]);
+ rules_count = (RTA_PAYLOAD(tb[TCA_CANPRIO_RULES]) / sizeof(struct can_filter));
- //printf("TCA_CANPRIO_RULES count = %d\n", rules_count);
for(i = 0; i < rules_count; i++) {
- fprintf(f, "match 0x%lx:0x%lx ",
- (unsigned long)(canprio_rules[i].can_id),
- (unsigned long)(canprio_rules[i].can_mask));
- //FIXME differentiate among SFF and EFF
+ if (canprio_rules[i].can_id & CAN_EFF_FLAG) {
+ fprintf(f, "matcheid 0x%lx:0x%lx ",
+ (unsigned long)(canprio_rules[i].can_id & CAN_EFF_MASK),
+ (unsigned long)(canprio_rules[i].can_mask & CAN_EFF_MASK));
+ }
+ else {
+ fprintf(f, "matchid 0x%lx:0x%lx ",
+ (unsigned long)(canprio_rules[i].can_id),
+ (unsigned long)(canprio_rules[i].can_mask));
+ }
}
}
-*/
+
return 0;
}