... and make necessary changes to make it compile.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/itrafmon.c | 38 ++++++--------------------------------
src/tcptable.c | 21 +++++++++++++++++++++
src/tcptable.h | 5 +++++
3 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/src/itrafmon.c b/src/itrafmon.c
index f1eda1f..e75eac2 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -67,15 +67,6 @@ static void uniq_help(int what)
STATUSBARATTR);
}
-/* Mark general packet count indicators */
-
-static void prepare_statwin(WINDOW * win)
-{
- wattrset(win, IPSTATLABELATTR);
- mvwprintw(win, 0, 1, "Packets captured:");
- mvwaddch(win, 0, 45 * COLS / 80, ACS_VLINE);
-}
-
static void markactive(int curwin, WINDOW * tw, WINDOW * ow)
{
WINDOW *win1;
@@ -101,14 +92,6 @@ static void markactive(int curwin, WINDOW * tw, WINDOW * ow)
whline(win2, ACS_HLINE, 8);
}
-static void show_stats(WINDOW * win, unsigned long long total)
-{
- wattrset(win, IPSTATATTR);
- wmove(win, 0, 35 * COLS / 80);
- printlargenum(total, win);
-}
-
-
/*
* Scrolling and paging routines for the upper (TCP) window
*/
@@ -601,9 +584,6 @@ void ipmon(time_t facilitytime, char *ifptr)
struct timeval updtime;
time_t closedint = 0;
- WINDOW *statwin;
- PANEL *statpanel;
-
WINDOW *sortwin;
PANEL *sortpanel;
@@ -662,12 +642,6 @@ void ipmon(time_t facilitytime, char *ifptr)
init_tcp_table(&table);
init_othp_table(&othptbl);
- statwin = newwin(1, COLS, LINES - 2, 0);
- statpanel = new_panel(statwin);
- wattrset(statwin, IPSTATLABELATTR);
- mvwprintw(statwin, 0, 0, "%*c", COLS, ' ');
- prepare_statwin(statwin);
- show_stats(statwin, 0);
markactive(curwin, table.borderwin, othptbl.borderwin);
update_panels();
doupdate();
@@ -771,7 +745,7 @@ void ipmon(time_t facilitytime, char *ifptr)
*/
if (screen_update_needed(&tv, &updtime)) {
- show_stats(statwin, total_pkts);
+ show_stats(table.statwin, total_pkts);
update_panels();
doupdate();
@@ -786,10 +760,10 @@ void ipmon(time_t facilitytime, char *ifptr)
if (rate_msecs > 1000) {
update_flowrate(&table, rate_msecs);
if (table.barptr != NULL) {
- print_flowrate(table.barptr, statwin);
+ print_flowrate(table.barptr, table.statwin);
} else {
- wattrset(statwin, IPSTATATTR);
- mvwprintw(statwin, 0, statx,
+ wattrset(table.statwin, IPSTATATTR);
+ mvwprintw(table.statwin, 0, statx,
"No TCP entries ");
}
tv_rate = tv;
@@ -1132,14 +1106,14 @@ err:
del_panel(table.borderpanel);
del_panel(othptbl.othppanel);
del_panel(othptbl.borderpanel);
- del_panel(statpanel);
+ del_panel(table.statpanel);
update_panels();
doupdate();
delwin(table.tcpscreen);
delwin(table.borderwin);
delwin(othptbl.othpwin);
delwin(othptbl.borderwin);
- delwin(statwin);
+ delwin(table.statwin);
destroytcptable(&table);
destroyothptable(&othptbl);
packet_destroy(&pkt);
diff --git a/src/tcptable.c b/src/tcptable.c
index 35a0bb0..06d1572 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -96,6 +96,20 @@ static void print_tcp_num_entries(struct tcptable *table)
table->count);
}
+static void prepare_statwin(WINDOW *win)
+{
+ wattrset(win, IPSTATLABELATTR);
+ mvwprintw(win, 0, 1, "Packets captured:");
+ mvwaddch(win, 0, 45 * COLS / 80, ACS_VLINE);
+}
+
+void show_stats(WINDOW *win, unsigned long long total)
+{
+ wattrset(win, IPSTATATTR);
+ wmove(win, 0, 35 * COLS / 80);
+ printlargenum(total, win);
+}
+
void init_tcp_table(struct tcptable *table)
{
int i;
@@ -137,6 +151,13 @@ void init_tcp_table(struct tcptable *table)
tx_stdwinset(table->tcpscreen);
print_tcp_num_entries(table);
+ table->statwin = newwin(1, COLS, LINES - 2, 0);
+ table->statpanel = new_panel(table->statwin);
+ wattrset(table->statwin, IPSTATLABELATTR);
+ mvwprintw(table->statwin, 0, 0, "%*c", COLS, ' ');
+ prepare_statwin(table->statwin);
+ show_stats(table->statwin, 0);
+
/*
* Initialize hash table to nulls
*/
diff --git a/src/tcptable.h b/src/tcptable.h
index 9fe0063..ff692fe 100644
--- a/src/tcptable.h
+++ b/src/tcptable.h
@@ -96,12 +96,17 @@ struct tcptable {
unsigned int imaxy; /* number of lines inside the border */
int ifnamew; /* interface name width to display */
int mode;
+
WINDOW *tcpscreen;
PANEL *tcppanel;
WINDOW *borderwin;
PANEL *borderpanel;
+ WINDOW *statwin;
+ PANEL *statpanel;
};
+void show_stats(WINDOW *win, unsigned long long total);
+
void init_tcp_table(struct tcptable *table);
struct tcptableent *addentry(struct tcptable *table,
--
1.8.4