From e47a1b4b26673ab7b9783f50366fff8a5300c8b8 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Tue, 20 Nov 2007 18:37:30 +0000 Subject: [PATCH] Changed color order at colorized output. Remove index cache zombies when unloading CAN drivers. Modified index cache failure message. --- candump.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/candump.c b/candump.c index c5ce33b..ce5ca42 100644 --- a/candump.c +++ b/candump.c @@ -79,7 +79,7 @@ #define MAGENTA ATTBOLD FGMAGENTA #define CYAN ATTBOLD FGCYAN -const char col_on [MAXDEV][19] = {BOLD, MAGENTA, GREEN, BLUE, CYAN, RED}; +const char col_on [MAXDEV][19] = {BLUE, RED, GREEN, BOLD, MAGENTA, CYAN}; const char col_off [] = ATTRESET; static char devname[MAXDEV][IFNAMSIZ+1]; @@ -132,12 +132,21 @@ int idx2dindex(int ifidx, int socket) { /* create new interface index cache entry */ + /* remove index cache zombies first */ + for (i=0; i < MAXDEV; i++) { + if (dindex[i]) { + ifr.ifr_ifindex = dindex[i]; + if (ioctl(socket, SIOCGIFNAME, &ifr) < 0) + dindex[i] = 0; + } + } + for (i=0; i < MAXDEV; i++) if (!dindex[i]) /* free entry */ break; if (i == MAXDEV) { - printf("BUG in interface index cache! MAXDEV?\n"); + printf("Interface index cache only supports %d interfaces.\n", MAXDEV); exit(1); } -- 2.39.2