diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-09-22 15:06:45 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-09-22 15:06:45 -0700 |
commit | f5913533f93cb51a64771fbc2426d67f2fe571c7 (patch) | |
tree | 9d90d45dde101d23dc2fda104f604db2d5979de6 /pcap-usb-linux.c | |
parent | 16684eff2ae63873960a632db205dacb2a3f23b1 (diff) |
Fix stats routine for text monitor.
The field giving the number of dropped URBs is "text_lost", not
"nreaders".
When scanning the values of fields, we need to get the count of
characters, just as we do when scanning the names of fields, so we know
how much to skip past the field.
Initialize text_dropped to 0 before scanning the file, so it's always
set.
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r-- | pcap-usb-linux.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index 589cd568..36bc6980 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -976,6 +976,10 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats) } string[ret] = 0; + stats->ps_recv = handlep->packets_read; + stats->ps_drop = 0; /* unless we find text_lost */ + stats->ps_ifdrop = 0; + /* extract info on dropped urbs */ for (consumed=0; consumed < ret; ) { /* from the sscanf man page: @@ -992,18 +996,16 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats) break; consumed += cnt; ptr += cnt; - if (strcmp(token, "nreaders") == 0) - ntok = sscanf(ptr, "%d", &stats->ps_drop); + if (strcmp(token, "text_lost") == 0) + ntok = sscanf(ptr, "%d", &stats->ps_drop, &cnt); else - ntok = sscanf(ptr, "%d", &dummy); - if (ntok != 1) + ntok = sscanf(ptr, "%d", &dummy, &cnt); + if ((ntok != 1) || (cnt < 0)) break; consumed += cnt; ptr += cnt; } - stats->ps_recv = handlep->packets_read; - stats->ps_ifdrop = 0; return 0; } |