]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - tc/f_canprio.c
It is possible to pass multiple rules for one instance of a filter.
[lisovros/iproute2_canprio.git] / tc / f_canprio.c
index 18c9294fe285995ed3549698add1f838fe953d13..e202b55e67f99fd2c26b7bc5ecf5902d0e30d088 100644 (file)
 #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)
 {
@@ -29,7 +35,7 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
        struct rtattr *tail;
        long h = 0;
        __u32 canid, canid_mask;
-
+       int rules_count = 0;
 
        if (argc == 0)
                return 0;
@@ -61,8 +67,9 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
 
                        //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 ||
@@ -88,7 +95,9 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
                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;
@@ -114,12 +123,10 @@ static int canprio_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt
                        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;