Commit a26049db authored by pdw's avatar pdw

spec file now generated with correct version number.

parent 8010c98d
......@@ -8,6 +8,7 @@ Added service resolution toggle ("R")
Added on-line help ("h")
More fixes to rate display
Improved interface selection (excludes lo:* and vmnet*)
Added bandwidth-in-bytes option.
0.8
......
......@@ -59,7 +59,7 @@ uninstall:
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *~ *.o core iftop
rm -f *~ *.o core iftop iftop.spec
tarball: depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE)
mkdir iftop-$(VERSION)
......@@ -75,5 +75,9 @@ depend: $(SRCS)
nodepend:
rm -f depend
iftop.spec: iftop.spec.in Makefile
sed 's/__VERSION__/$(VERSION)/' < iftop.spec.in > iftop.spec
include depend
Summary: iftop - provides realtime bandwith usage on an interface
Name: iftop
Version: 0.8
Version: __VERSION__
Release: 1
License: GPL
Group: Applications/Internet
Source0: http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.8.tar.gz
Source0: http://www.ex-parrot.com/~pdw/iftop/download/iftop-__VERSION__.tar.gz
URL: http://www.ex-parrot.com/~pdw/iftop/
Buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n)
Packager: Riku Meskanen <mesrik@cc.jyu.fi>
......
......@@ -18,7 +18,7 @@
options_t options;
char optstr[] = "+i:f:n:dhpbP";
char optstr[] = "+i:f:n:dhpbBP";
/* Global options. */
......@@ -94,6 +94,7 @@ static void set_defaults() {
options.aggregate_dest = 0;
options.paused = 0;
options.showhelp = 0;
options.bandwidth_in_bytes = 0;
}
static void die(char *msg) {
......@@ -156,6 +157,7 @@ static void usage(FILE *fp) {
" -p run in promiscuous mode (show traffic between other\n"
" hosts on the same network segment)\n"
" -b don't display a bar graph of traffic\n"
" -B Display bandwidth in bytes\n"
" -i interface listen on named interface\n"
" -f filter code use filter code to select packets to count\n"
" (default: none, but only IP packets are counted)\n"
......@@ -207,6 +209,9 @@ void options_read(int argc, char **argv) {
options.showbars = 0;
break;
case 'B':
options.bandwidth_in_bytes = 1;
break;
case '?':
fprintf(stderr, "iftop: unknown option -%c\n", optopt);
......
......@@ -10,11 +10,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
typedef enum {
OPTION_AGGREGATE_OFF,
OPTION_AGGREGATE_SRC,
OPTION_AGGREGATE_DEST
} option_aggregate_t;
typedef enum {
OPTION_PORTS_OFF,
......@@ -43,6 +38,7 @@ typedef struct {
int aggregate_dest;
int paused;
int showhelp;
int bandwidth_in_bytes;
} options_t;
......
......@@ -47,7 +47,7 @@
int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
#define UNIT_DIVISIONS 4
char* unit_bits[UNIT_DIVISIONS] = { "b", "K", "M", "G"};
char* unit_bits[UNIT_DIVISIONS] = { "b", "Kb", "Mb", "Gb"};
char* unit_bytes[UNIT_DIVISIONS] = { "B", "KB", "MB", "GB"};
typedef struct host_pair_line_tag {
......@@ -89,6 +89,11 @@ void readable_size(float n, char* buf, int bsize, int ksize, int bytes) {
int i = 0;
float size = 1;
/* Convert to bits? */
if(bytes == 0) {
n *= 8;
}
while(1) {
if(n < size * 1000 || i >= UNIT_DIVISIONS - 1) {
snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
......@@ -140,7 +145,7 @@ static void draw_bar_scale(int* y) {
for (i = 1; i <= scale[rateidx].max; i *= scale[rateidx].interval) {
char s[40], *p;
int x;
readable_size(i, s, sizeof s, 1000, 0);
readable_size(i / 8, s, sizeof s, 1000, 0);
p = s + strspn(s, " ");
x = get_bar_length(i);
mvaddch(*y + 1, x, ACS_BTEE);
......@@ -171,10 +176,10 @@ void draw_line_totals(int y, host_pair_line* line) {
for(j = 0; j < HISTORY_DIVISIONS; j++) {
t = history_length(j);
readable_size(8 * line->sent[j] / t, buf, 10, 1024, 0);
readable_size(line->sent[j] / t, buf, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y, x, buf);
readable_size(8 * line->recv[j] / t, buf, 10, 1024, 0);
readable_size(line->recv[j] / t, buf, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y+1, x, buf);
x += 8;
}
......@@ -462,13 +467,13 @@ void ui_print() {
mvaddstr(y, 0, "total: ");
mvaddstr(y+1, 0, " peak: ");
readable_size((totals.recv[0] + totals.sent[0]) * 8 / RESOLUTION, line, 10, 1024, 0);
readable_size((totals.recv[0] + totals.sent[0]) / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y, 8, line);
readable_size(peaktotal * 8 / RESOLUTION, line, 10, 1024, 0);
readable_size(peaktotal / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y+1, 8, line);
readable_size((peakrecv + peaksent) * 8 / RESOLUTION, line, 10, 1024, 0);
readable_size((peakrecv + peaksent) / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y+1, 8, line);
mvaddstr(y, 18, "TX: ");
......@@ -484,10 +489,10 @@ void ui_print() {
/* Peak traffic */
mvaddstr(y, 33, "peaks: ");
readable_size(peaksent * 8 / RESOLUTION, line, 10, 1024, 0);
readable_size(peaksent / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y, 39, line);
readable_size(peakrecv * 8 / RESOLUTION, line, 10, 1024, 0);
readable_size(peakrecv / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
mvaddstr(y+1, 39, line);
mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 8, "totals:");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment