ifstat.c (247037) | ifstat.c (265782) |
---|---|
1/* 2 * Copyright (c) 2003, Trent Nelson, <trent@arpa.com>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTIFSTAT_ERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 2003, Trent Nelson, <trent@arpa.com>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTIFSTAT_ERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/usr.bin/systat/ifstat.c 247037 2013-02-20 14:19:09Z melifaro $ | 28 * $FreeBSD: head/usr.bin/systat/ifstat.c 265782 2014-05-09 16:20:55Z melifaro $ |
29 */ 30 31#include <sys/types.h> 32#include <sys/socket.h> 33#include <sys/sysctl.h> 34#include <net/if.h> 35#include <net/if_mib.h> 36 --- 35 unchanged lines hidden (view full) --- 72 u_long if_out_curtraffic; 73 u_long if_in_traffic_peak; 74 u_long if_out_traffic_peak; 75 u_long if_in_curpps; 76 u_long if_out_curpps; 77 u_long if_in_pps_peak; 78 u_long if_out_pps_peak; 79 u_int if_row; /* Index into ifmib sysctl */ | 29 */ 30 31#include <sys/types.h> 32#include <sys/socket.h> 33#include <sys/sysctl.h> 34#include <net/if.h> 35#include <net/if_mib.h> 36 --- 35 unchanged lines hidden (view full) --- 72 u_long if_out_curtraffic; 73 u_long if_in_traffic_peak; 74 u_long if_out_traffic_peak; 75 u_long if_in_curpps; 76 u_long if_out_curpps; 77 u_long if_in_pps_peak; 78 u_long if_out_pps_peak; 79 u_int if_row; /* Index into ifmib sysctl */ |
80 u_int if_ypos; /* 0 if not being displayed */ | 80 int if_ypos; /* -1 if not being displayed */ |
81 u_int display; 82 u_int match; 83}; 84 85extern int curscale; 86extern char *matchline; 87extern int showpps; 88extern int needsort; --- 116 unchanged lines hidden (view full) --- 205} 206 207void 208showifstat(void) 209{ 210 struct if_stat *ifp = NULL; 211 212 SLIST_FOREACH(ifp, &curlist, link) { | 81 u_int display; 82 u_int match; 83}; 84 85extern int curscale; 86extern char *matchline; 87extern int showpps; 88extern int needsort; --- 116 unchanged lines hidden (view full) --- 205} 206 207void 208showifstat(void) 209{ 210 struct if_stat *ifp = NULL; 211 212 SLIST_FOREACH(ifp, &curlist, link) { |
213 if (ifp->display == 0 || (ifp->match == 0) || 214 ifp->if_ypos > LINES - 3 - 1) 215 continue; 216 PUTNAME(ifp); 217 PUTRATE(col2, ifp->if_ypos); 218 PUTRATE(col3, ifp->if_ypos); 219 PUTTOTAL(col4, ifp->if_ypos); | 213 if (ifp->if_ypos < LINES - 3 && ifp->if_ypos != -1) 214 if (ifp->display == 0 || ifp->match == 0) { 215 wmove(wnd, ifp->if_ypos, 0); 216 wclrtoeol(wnd); 217 wmove(wnd, ifp->if_ypos + 1, 0); 218 wclrtoeol(wnd); 219 } 220 else { 221 PUTNAME(ifp); 222 PUTRATE(col2, ifp->if_ypos); 223 PUTRATE(col3, ifp->if_ypos); 224 PUTTOTAL(col4, ifp->if_ypos); 225 } |
220 } 221 222 return; 223} 224 225int 226initifstat(void) 227{ --- 192 unchanged lines hidden (view full) --- 420 if (matchline && !check_match(ifp->if_mib.ifmd_name)) 421 ifp->match = 0; 422 else 423 ifp->match = 1; 424 if (ifp->display && ifp->match) { 425 ifp->if_ypos = y; 426 y += ROW_SPACING; 427 } | 226 } 227 228 return; 229} 230 231int 232initifstat(void) 233{ --- 192 unchanged lines hidden (view full) --- 426 if (matchline && !check_match(ifp->if_mib.ifmd_name)) 427 ifp->match = 0; 428 else 429 ifp->match = 1; 430 if (ifp->display && ifp->match) { 431 ifp->if_ypos = y; 432 y += ROW_SPACING; 433 } |
434 else 435 ifp->if_ypos = -1; |
|
428 } 429 430 needsort = 0; 431 needclear = 1; 432} 433 434static 435unsigned int --- 35 unchanged lines hidden (view full) --- 471int 472cmdifstat(const char *cmd, const char *args) 473{ 474 int retval = 0; 475 476 retval = ifcmd(cmd, args); 477 /* ifcmd() returns 1 on success */ 478 if (retval == 1) { | 436 } 437 438 needsort = 0; 439 needclear = 1; 440} 441 442static 443unsigned int --- 35 unchanged lines hidden (view full) --- 479int 480cmdifstat(const char *cmd, const char *args) 481{ 482 int retval = 0; 483 484 retval = ifcmd(cmd, args); 485 /* ifcmd() returns 1 on success */ 486 if (retval == 1) { |
479 showifstat(); 480 refresh(); | |
481 if (needclear) { | 487 if (needclear) { |
488 showifstat(); 489 refresh(); |
|
482 werase(wnd); 483 labelifstat(); 484 needclear = 0; 485 } 486 } | 490 werase(wnd); 491 labelifstat(); 492 needclear = 0; 493 } 494 } |
487 | |
488 return (retval); 489} | 495 return (retval); 496} |