]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - tc/q_dsmark.c
Add reference to tc-codel(8) to the SEE ALSO section
[lisovros/iproute2_canprio.git] / tc / q_dsmark.c
index 8a1cd4d836ea55487e0cae2a630a562a0061b0fd..05185c0096c9ac60b80d22891014e79cac4586eb 100644 (file)
@@ -19,9 +19,6 @@
 #include "tc_util.h"
 
 
-#define usage() return(-1)
-
-
 static void explain(void)
 {
        fprintf(stderr,"Usage: dsmark indices INDICES [ default_index "
@@ -71,7 +68,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
                explain();
                return -1;
        }
-       tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
+       tail = NLMSG_TAIL(n);
        addattr_l(n,1024,TCA_OPTIONS,NULL,0);
        addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind));
        if (dflt != -1) {
@@ -80,7 +77,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
            addattr_l(n,1024,TCA_DSMARK_DEFAULT_INDEX,&tmp,sizeof(tmp));
        }
        if (set_tc_index) addattr_l(n,1024,TCA_DSMARK_SET_TC_INDEX,NULL,0);
-       tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail;
+       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
        return 0;
 }
 
@@ -98,7 +95,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
        __u8 tmp;
        char *end;
 
-       tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
+       tail = NLMSG_TAIL(n);
        addattr_l(n,1024,TCA_OPTIONS,NULL,0);
        while (argc > 0) {
                if (!strcmp(*argv,"mask")) {
@@ -126,7 +123,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
                argc--;
                argv++;
        }
-       tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail;
+       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
        return 0;
 }
 
@@ -143,44 +140,35 @@ static int dsmark_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
                if (!RTA_PAYLOAD(tb[TCA_DSMARK_MASK]))
                        fprintf(stderr,"dsmark: empty mask\n");
                else fprintf(f,"mask 0x%02x ",
-                           *(__u8 *) RTA_DATA(tb[TCA_DSMARK_MASK]));
+                           rta_getattr_u8(tb[TCA_DSMARK_MASK]));
        }
        if (tb[TCA_DSMARK_VALUE]) {
                if (!RTA_PAYLOAD(tb[TCA_DSMARK_VALUE]))
                        fprintf(stderr,"dsmark: empty value\n");
                else fprintf(f,"value 0x%02x ",
-                           *(__u8 *) RTA_DATA(tb[TCA_DSMARK_VALUE]));
+                           rta_getattr_u8(tb[TCA_DSMARK_VALUE]));
        }
        if (tb[TCA_DSMARK_INDICES]) {
                if (RTA_PAYLOAD(tb[TCA_DSMARK_INDICES]) < sizeof(__u16))
                        fprintf(stderr,"dsmark: indices too short\n");
                else fprintf(f,"indices 0x%04x ",
-                           *(__u16 *) RTA_DATA(tb[TCA_DSMARK_INDICES]));
+                           rta_getattr_u16(tb[TCA_DSMARK_INDICES]));
        }
        if (tb[TCA_DSMARK_DEFAULT_INDEX]) {
                if (RTA_PAYLOAD(tb[TCA_DSMARK_DEFAULT_INDEX]) < sizeof(__u16))
                        fprintf(stderr,"dsmark: default_index too short\n");
                else fprintf(f,"default_index 0x%04x ",
-                           *(__u16 *) RTA_DATA(tb[TCA_DSMARK_DEFAULT_INDEX]));
+                           rta_getattr_u16(tb[TCA_DSMARK_DEFAULT_INDEX]));
        }
        if (tb[TCA_DSMARK_SET_TC_INDEX]) fprintf(f,"set_tc_index ");
        return 0;
 }
 
 
-static int dsmark_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
-{
-       return 0;
-}
-
-
-struct qdisc_util dsmark_util = {
-       NULL,
-       "dsmark",
-       dsmark_parse_opt,
-       dsmark_print_opt,
-       dsmark_print_xstats,
-
-       dsmark_parse_class_opt,
-       dsmark_print_opt
+struct qdisc_util dsmark_qdisc_util = {
+       .id             = "dsmark",
+       .parse_qopt     = dsmark_parse_opt,
+       .print_qopt     = dsmark_print_opt,
+       .parse_copt     = dsmark_parse_class_opt,
+       .print_copt     = dsmark_print_opt,
 };