]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/f_basic.c
Merge branch 'master' into next
[mirror_iproute2.git] / tc / f_basic.c
index 264f35840b0594744bab37c19ef6cc5664546b1a..7b19cea6e87e75c060ab822d5463ee73370a1405 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * f_basic.c           Basic Classifier
  *
- *             This program is free software; you can u32istribute it and/or
+ *             This program is free software; you can distribute it and/or
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <syslog.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 
 static void explain(void)
 {
-       fprintf(stderr, "Usage: ... basic [ match EMATCH_TREE ] [ police POLICE_SPEC ]\n");
-       fprintf(stderr, "                 [ action ACTION_SPEC ] [ classid CLASSID ]\n");
-       fprintf(stderr, "\n");
-       fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
-       fprintf(stderr, "       FILTERID := X:Y:Z\n");
+       fprintf(stderr,
+               "Usage: ... basic [ match EMATCH_TREE ]\n"
+               "                 [ action ACTION_SPEC ] [ classid CLASSID ]\n"
+               "\n"
+               "Where: SELECTOR := SAMPLE SAMPLE ...\n"
+               "       FILTERID := X:Y:Z\n"
+               "       ACTION_SPEC := ... look at individual actions\n"
+               "\n"
+               "NOTE: CLASSID is parsed as hexadecimal input.\n");
 }
 
 static int basic_parse_opt(struct filter_util *qu, char *handle,
@@ -41,9 +44,6 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
        struct rtattr *tail;
        long h = 0;
 
-       if (argc == 0)
-               return 0;
-
        if (handle) {
                h = strtol(handle, NULL, 0);
                if (h == LONG_MIN || h == LONG_MAX) {
@@ -52,10 +52,12 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
                        return -1;
                }
        }
-               
        t->tcm_handle = h;
 
-       tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+       if (argc == 0)
+               return 0;
+
+       tail = (struct rtattr *)(((void *)n)+NLMSG_ALIGN(n->nlmsg_len));
        addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
 
        while (argc > 0) {
@@ -68,7 +70,8 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
                        continue;
                } else if (matches(*argv, "classid") == 0 ||
                           strcmp(*argv, "flowid") == 0) {
-                       unsigned handle;
+                       unsigned int handle;
+
                        NEXT_ARG();
                        if (get_tc_classid(&handle, *argv)) {
                                fprintf(stderr, "Illegal \"classid\"\n");
@@ -101,7 +104,7 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
                argc--; argv++;
        }
 
-       tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+       tail->rta_len = (((void *)n)+n->nlmsg_len) - (void *)tail;
        return 0;
 }
 
@@ -121,7 +124,7 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
        if (tb[TCA_BASIC_CLASSID]) {
                SPRINT_BUF(b1);
                fprintf(f, "flowid %s ",
-                       sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
+                       sprint_tc_classid(rta_getattr_u32(tb[TCA_BASIC_CLASSID]), b1));
        }
 
        if (tb[TCA_BASIC_EMATCHES])
@@ -133,7 +136,7 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
        }
 
        if (tb[TCA_BASIC_ACT]) {
-               tc_print_action(f, tb[TCA_BASIC_ACT]);
+               tc_print_action(f, tb[TCA_BASIC_ACT], 0);
        }
 
        return 0;