X-Git-Url: https://rtime.felk.cvut.cz/gitweb/sojka/can-utils.git/blobdiff_plain/12f91703381a2595433d08a27c5ec0b1fc0f15ea..HEAD:/cansniffer.c diff --git a/cansniffer.c b/cansniffer.c index 1d7eb64..71ca721 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -1,7 +1,3 @@ -/* - * $Id$ - */ - /* * can-sniffer.c * @@ -41,7 +37,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * - * Send feedback to + * Send feedback to * */ @@ -102,15 +98,15 @@ const char anichar[MAXANI] = {'|', '/', '-', '\\', '|', '/', '-', '\\'}; #define STARTLINESTR "X time ID data ... " struct snif { - int flags; - long hold; - long timeout; - struct timeval laststamp; - struct timeval currstamp; - struct can_frame last; - struct can_frame current; - struct can_frame marker; - struct can_frame notch; + int flags; + long hold; + long timeout; + struct timeval laststamp; + struct timeval currstamp; + struct can_frame last; + struct can_frame current; + struct can_frame marker; + struct can_frame notch; } sniftab[2048]; @@ -118,13 +114,15 @@ extern int optind, opterr, optopt; static int running = 1; static int clearscreen = 1; -static int notch = 0; +static int notch; +static int filter_id_only; static long timeout = TIMEOUT; static long hold = HOLD; static long loop = LOOP; -static unsigned char binary = 0; -static unsigned char binary_gap = 0; -static unsigned char color = 0; +static unsigned char binary; +static unsigned char binary_gap; +static unsigned char color; +static char *interface; void rx_setup (int fd, int id); void rx_delete (int fd, int id); @@ -137,613 +135,622 @@ void readsettings(char* name, int sockfd); void print_usage(char *prg) { - const char manual [] = { - "commands that can be entered at runtime:\n" - "\n" - "q - quit\n" - "b - toggle binary / HEX-ASCII output\n" - "B - toggle binary with gap / HEX-ASCII output (exceeds 80 chars!)\n" - "c - toggle color mode\n" - "# - notch currently marked/changed bits (can be used repeatedly)\n" - "* - clear notched marked\n" - "rMYNAME - read settings file (filter/notch)\n" - "wMYNAME - write settings file (filter/notch)\n" - "+FILTER - add CAN-IDs to sniff\n" - "-FILTER - remove CAN-IDs to sniff\n" - "\n" - "FILTER can be a single CAN-ID or a CAN-ID/Bitmask:\n" - "+1F5 - add CAN-ID 0x1F5\n" - "-42E - remove CAN-ID 0x42E\n" - "-42E7FF - remove CAN-ID 0x42E (using Bitmask)\n" - "-500700 - remove CAN-IDs 0x500 - 0x5FF\n" - "+400600 - add CAN-IDs 0x400 - 0x5FF\n" - "+000000 - add all CAN-IDs\n" - "-000000 - remove all CAN-IDs\n" - "\n" - "if (id & filter) == (sniff-id & filter) the action (+/-) is performed,\n" - "which is quite easy when the filter is 000\n" - "\n" - }; - - fprintf(stderr, "\nUsage: %s [can-interface]\n", prg); - fprintf(stderr, "Options: -m (initial FILTER default 0x00000000)\n"); - fprintf(stderr, " -v (initial FILTER default 0x00000000)\n"); - fprintf(stderr, " -q (quiet - all IDs deactivated)\n"); - fprintf(stderr, " -r (read %sname from file)\n", SETFNAME); - fprintf(stderr, " -b (start with binary mode)\n"); - fprintf(stderr, " -B (start with binary mode with gap - exceeds 80 chars!)\n"); - fprintf(stderr, " -c (color changes)\n"); - fprintf(stderr, " -t