]> rtime.felk.cvut.cz Git - sojka/can-utils.git/commitdiff
cangw: fix inverse filter display when printing the configured rules
authorOliver Hartkopp <socketcan@hartkopp.net>
Tue, 29 Jan 2013 19:50:46 +0000 (20:50 +0100)
committerOliver Hartkopp <socketcan@hartkopp.net>
Tue, 29 Jan 2013 19:50:46 +0000 (20:50 +0100)
A configured inverse filter e.g.

cangw -A -s can0 -d can1 -e -f 123~7FF

has been displayed with 'cangw -L' like this:

cangw -A -s can0 -d can1 -e -f 20000123:7FF # 0 handled 0 dropped 0 deleted

While 0x20000000 was the value of CAN_INV_FILTER.

This patch fixes the output to the expected display:

cangw -A -s can0 -d can1 -e -f 123~7FF # 0 handled 0 dropped 0 deleted

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
cangw.c

diff --git a/cangw.c b/cangw.c
index 4b4595c63fb3464987e3ac161f6e49e162d34fb0..802aa8627d145d6e2e88251282130bda1e15db14 100644 (file)
--- a/cangw.c
+++ b/cangw.c
@@ -98,7 +98,10 @@ void printfilter(const void *data)
 {
        struct can_filter *filter = (struct can_filter *)data;
 
-       printf("-f %03X:%X ", filter->can_id, filter->can_mask);
+       if (filter->can_id & CAN_INV_FILTER)
+               printf("-f %03X~%X ", (filter->can_id & ~CAN_INV_FILTER), filter->can_mask);
+       else
+               printf("-f %03X:%X ", filter->can_id, filter->can_mask);
 }
 
 void printmod(const char *type, const void *data)