]> rtime.felk.cvut.cz Git - sojka/can-utils.git/blobdiff - cangw.c
slcan_attach: Added new commandline option to specify the created netdevice name.
[sojka/can-utils.git] / cangw.c
diff --git a/cangw.c b/cangw.c
index 4c7140ce0417cea432766cb594ef9b7fd7dea340..fbc230d4599e9a4532b14ac945bf37e0a6f829fa 100644 (file)
--- a/cangw.c
+++ b/cangw.c
@@ -203,7 +203,9 @@ void print_usage(char *prg)
        fprintf(stderr, "           -p <profile>:[<profile_data>] (CRC8 checksum profile & parameters)\n");
        fprintf(stderr, "\nValues are given and expected in hexadecimal values. Leading 0s can be omitted.\n");
        fprintf(stderr, "\n");
-       fprintf(stderr, "<filter> is a <value>:<mask> CAN identifier filter\n");
+       fprintf(stderr, "<filter> is a <value><mask> CAN identifier filter\n");
+       fprintf(stderr, "   <can_id>:<can_mask> (matches when <received_can_id> & mask == can_id & mask)\n");
+       fprintf(stderr, "   <can_id>~<can_mask> (matches when <received_can_id> & mask != can_id & mask)\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "<mod> is a CAN frame modification instruction consisting of\n");
        fprintf(stderr, "<instruction>:<can_frame-elements>:<can_id>.<can_dlc>.<can_data>\n");
@@ -326,8 +328,7 @@ int parse_mod(char *optarg, struct modattr *modmsg)
                ptr++;
        }
 
-       if (sscanf(++ptr, "%lx.%hhx.%16s",
-                  (long unsigned int *)&modmsg->cf.can_id,
+       if (sscanf(++ptr, "%x.%hhx.%16s", &modmsg->cf.can_id,
                   (unsigned char *)&modmsg->cf.can_dlc, hexdata) != 3)
                return 5;
 
@@ -591,9 +592,12 @@ int main(int argc, char **argv)
                        break;
 
                case 'f':
-                       if (sscanf(optarg, "%lx:%lx",
-                                  (long unsigned int *)&filter.can_id, 
-                                  (long unsigned int *)&filter.can_mask) == 2) {
+                       if (sscanf(optarg, "%x:%x", &filter.can_id,
+                                  &filter.can_mask) == 2) {
+                               have_filter = 1;
+                       } else if (sscanf(optarg, "%x~%x", &filter.can_id,
+                                         &filter.can_mask) == 2) {
+                               filter.can_id |= CAN_INV_FILTER;
                                have_filter = 1;
                        } else {
                                printf("Bad filter definition '%s'.\n", optarg);
@@ -742,7 +746,7 @@ int main(int argc, char **argv)
        }
 
        /* clean netlink receive buffer */
-       bzero(rxbuf, sizeof(rxbuf));
+       memset(rxbuf, 0x0, sizeof(rxbuf));
 
        if (cmd != LIST) {