Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/iptraf.c | 12 +++---------
src/options.c | 12 +++++++++---
src/options.h | 4 +---
src/serv.c | 7 ++++++-
src/serv.h | 2 +-
5 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/iptraf.c b/src/iptraf.c
index 11fbc42..a7335a5 100644
--- a/src/iptraf.c
+++ b/src/iptraf.c
@@ -132,7 +132,6 @@ static void program_interface(struct OPTIONS *options)
char ifname[IFNAMSIZ];
char *ifptr = NULL;
- struct porttab *ports;
/*
* Load saved filter or graphing filter if specified
@@ -147,8 +146,6 @@ static void program_interface(struct OPTIONS *options)
indicate("");
}
- loadaddports(&ports);
-
tx_initmenu(&menu, 15, 35, (LINES - 16) / 2, (COLS - 35) / 2, BOXATTR,
STDATTR, HIGHATTR, BARSTDATTR, BARHIGHATTR, DESCATTR);
@@ -214,7 +211,7 @@ static void program_interface(struct OPTIONS *options)
case 2:
selectiface(ifname, WITHOUTALL, &aborted);
if (!aborted)
- servmon(ifname, ports, options, 0,
+ servmon(ifname, options, 0,
&ofilter);
break;
case 4:
@@ -237,7 +234,7 @@ static void program_interface(struct OPTIONS *options)
savefilters(&ofilter);
break;
case 9:
- setoptions(options, &ports);
+ setoptions(options);
saveoptions(options);
break;
case 11:
@@ -251,7 +248,6 @@ static void program_interface(struct OPTIONS *options)
tx_destroymenu(&menu);
- destroyporttab(ports);
erase();
update_panels();
doupdate();
@@ -495,9 +491,7 @@ int main(int argc, char **argv)
struct filterstate ofilter;
struct ffnode *fltfiles;
- struct porttab *ports;
- loadaddports(&ports);
/*
* Load saved filter or graphing filter if specified
*/
@@ -534,7 +528,7 @@ int main(int argc, char **argv)
else if (d_opt)
detstats(d_opt, &options, facilitytime, &ofilter);
else if (s_opt)
- servmon(s_opt, ports, &options, facilitytime, &ofilter);
+ servmon(s_opt, &options, facilitytime, &ofilter);
else if (z_opt)
packet_size_breakdown(&options, z_opt, facilitytime, &ofilter);
else
diff --git a/src/options.c b/src/options.c
index ee693de..fdbc608 100644
--- a/src/options.c
+++ b/src/options.c
@@ -246,7 +246,7 @@ static void settimeout(time_t *value, const char *units, int
allow_zero,
doupdate();
}
-void setoptions(struct OPTIONS *options, struct porttab **ports)
+void setoptions(struct OPTIONS *options)
{
int row = 1;
int trow = 1; /* row for timer submenu */
@@ -258,12 +258,17 @@ void setoptions(struct OPTIONS *options, struct porttab **ports)
WINDOW *statwin;
PANEL *statpanel;
+ struct porttab *ports;
+
if (!is_first_instance) {
tui_error(ANYKEY_MSG,
"Only the first instance of ipraf-ng"
" can configure");
return;
}
+
+ loadaddports(&ports);
+
makeoptionmenu(&menu);
statwin = newwin(15, 35, (LINES - 19) / 2 - 1, (COLS - 40) / 16 + 40);
@@ -365,10 +370,10 @@ void setoptions(struct OPTIONS *options, struct porttab **ports)
doupdate();
break;
case 12:
- addmoreports(ports);
+ addmoreports(&ports);
break;
case 13:
- removeaport(ports);
+ removeaport(&ports);
break;
case 15:
manage_eth_desc(ARPHRD_ETHER);
@@ -381,6 +386,7 @@ void setoptions(struct OPTIONS *options, struct porttab **ports)
indicatesetting(row, options, statwin);
} while (row != 18);
+ destroyporttab(ports);
tx_destroymenu(&menu);
del_panel(statpanel);
delwin(statwin);
diff --git a/src/options.h b/src/options.h
index f43c90b..c997f44 100644
--- a/src/options.h
+++ b/src/options.h
@@ -12,9 +12,7 @@ struct OPTIONS {
#define DEFAULT_UPDATE_DELAY 50000 /* usec screen delay if update rate 0 */
-#include "serv.h"
-
-void setoptions(struct OPTIONS *options, struct porttab **ports);
+void setoptions(struct OPTIONS *options);
void loadoptions(struct OPTIONS *options);
void saveoptions(struct OPTIONS *options);
diff --git a/src/serv.c b/src/serv.c
index 8757436..b64acec 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -789,7 +789,7 @@ static void update_serv_rates(struct portlist *list, WINDOW * win, int
actmode,
* The TCP/UDP service monitor
*/
-void servmon(char *ifname, struct porttab *ports, const struct OPTIONS *options,
+void servmon(char *ifname, const struct OPTIONS *options,
time_t facilitytime, struct filterstate *ofilter)
{
int logging = options->logging;
@@ -833,6 +833,8 @@ void servmon(char *ifname, struct porttab *ports, const struct OPTIONS
*options,
int fd;
+ struct porttab *ports;
+
/*
* Mark this facility
*/
@@ -850,6 +852,8 @@ void servmon(char *ifname, struct porttab *ports, const struct OPTIONS
*options,
return;
}
+ loadaddports(&ports);
+
if ((first_active_facility()) && (options->promisc)) {
init_promisc_list(&promisc_list);
save_promisc_list(promisc_list);
@@ -1172,6 +1176,7 @@ err:
update_panels();
doupdate();
destroyportlist(&list);
+ destroyporttab(ports);
pkt_cleanup();
strcpy(current_logfile, "");
}
diff --git a/src/serv.h b/src/serv.h
index b4e3101..78447ea 100644
--- a/src/serv.h
+++ b/src/serv.h
@@ -22,7 +22,7 @@ void removeaport(struct porttab **table);
#include "options.h"
#include "fltselect.h"
-void servmon(char *iface, struct porttab *ports, const struct OPTIONS *options,
+void servmon(char *iface, const struct OPTIONS *options,
time_t facilitytime, struct filterstate *ofilter);
#endif /* IPTRAF_NG_SERV_H */
--
1.7.8.4