On Mon, Sep 03, 2012 at 02:06:12PM +0200, Nikola Pajkovsky wrote:
we don't need it any more. the idea will be to have only one
running iptraf-ng
instance
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
Makefile | 2 -
src/detstats.c | 23 +--------
src/fltedit.c | 34 ++-----------
src/fltmgr.c | 21 +-------
src/fltmgr.h | 2 -
src/fltselect.c | 11 ----
src/hostmon.c | 31 ++---------
src/ifstats.c | 20 ++------
src/instances.c | 136 -------------------------------------------------
src/instances.h | 18 -------
src/iptraf-ng-compat.h | 1 -
src/iptraf.c | 35 -------------
src/itrafmon.c | 36 +++----------
src/options.c | 8 ---
src/pktsize.c | 17 +------
src/serv.c | 22 +-------
16 files changed, 25 insertions(+), 392 deletions(-)
delete mode 100644 src/instances.c
delete mode 100644 src/instances.h
diff --git a/Makefile b/Makefile
index c72ff7a..c8711db 100644
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,6 @@ iptraf-h += src/fltmgr.h
iptraf-h += src/ipfrag.h
iptraf-h += src/serv.h
iptraf-h += src/servname.h
-iptraf-h += src/instances.h
iptraf-h += src/timer.h
iptraf-h += src/ifaces.h
iptraf-h += src/error.h
@@ -133,7 +132,6 @@ iptraf-o += src/fltmgr.o
iptraf-o += src/ipfrag.o
iptraf-o += src/serv.o
iptraf-o += src/servname.o
-iptraf-o += src/instances.o
iptraf-o += src/timer.o
iptraf-o += src/revname.o
iptraf-o += src/pktsize.o
diff --git a/src/detstats.c b/src/detstats.c
index 43b442a..37c43bb 100644
--- a/src/detstats.c
+++ b/src/detstats.c
@@ -22,7 +22,6 @@ detstats.c - the interface statistics module
#include "attrs.h"
#include "serv.h"
#include "timer.h"
-#include "instances.h"
#include "logvars.h"
#include "promisc.h"
#include "error.h"
@@ -293,32 +292,17 @@ void detstats(char *iface, time_t facilitytime)
int fd;
- /*
- * Mark this facility
- */
-
- if (!facility_active(DSTATIDFILE, iface))
- mark_facility(DSTATIDFILE, "detailed interface statistics",
- iface);
- else {
- write_error("Detailed interface stats already monitoring %s", iface);
- return;
- }
-
if (!dev_up(iface)) {
err_iface_down();
- unmark_facility(DSTATIDFILE, iface);
return;
}
LIST_HEAD(promisc);
- if (options.promisc && first_active_facility()) {
+ if (options.promisc) {
promisc_init(&promisc, iface);
promisc_set_list(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, 1);
-
move(LINES - 1, 1);
stdexitkeyhelp();
statwin = newwin(LINES - 2, COLS, 1, 0);
@@ -591,13 +575,11 @@ err:
rate_destroy(&rate_in);
rate_destroy(&rate);
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, -1);
-
if (logging) {
signal(SIGUSR1, SIG_DFL);
writedstatlog(iface,
@@ -612,7 +594,6 @@ err:
del_panel(statpanel);
delwin(statwin);
- unmark_facility(DSTATIDFILE, iface);
strcpy(current_logfile, "");
pkt_cleanup();
update_panels();
diff --git a/src/fltedit.c b/src/fltedit.c
index cd926f1..50801ec 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -104,7 +104,6 @@ void savefilter(char *filename, struct filterlist *fl)
if (bw < 0) {
tui_error(ANYKEY_MSG, "Unable to save filter changes");
- clear_flt_tag();
return;
}
fe = fe->next_entry;
@@ -505,19 +504,11 @@ void definefilter(int *aborted)
int pfd;
int bw;
- /*
- * Lock facility
- */
-
- if (!mark_filter_change())
- return;
-
get_filter_description(ffile.desc, aborted, "");
- if (*aborted) {
- clear_flt_tag();
+ if (*aborted)
return;
- }
+
genname(time(NULL), fntemp);
pfd =
@@ -526,7 +517,6 @@ void definefilter(int *aborted)
if (pfd < 0) {
tui_error(ANYKEY_MSG, "Cannot create filter data file");
*aborted = 1;
- clear_flt_tag();
return;
}
@@ -537,7 +527,6 @@ void definefilter(int *aborted)
if (pfd < 0) {
listfileerr(1);
- clear_flt_tag();
return;
}
strcpy(ffile.filename, fntemp);
@@ -551,8 +540,6 @@ void definefilter(int *aborted)
modify_host_parameters(&fl);
savefilter(get_path(T_WORKDIR, fntemp), &fl);
destroyfilter(&fl);
-
- clear_flt_tag();
}
/*
@@ -566,21 +553,15 @@ void editfilter(int *aborted)
struct ffnode *ffile;
struct filterfileent *ffe;
- if (!mark_filter_change())
- return;
-
if (loadfilterlist(&flist) == 1) {
listfileerr(1);
destroyfilterlist(flist);
- clear_flt_tag();
return;
}
pickafilter(flist, &ffile, aborted);
- clear_flt_tag();
if ((*aborted)) {
destroyfilterlist(flist);
- clear_flt_tag();
return;
}
ffe = &(ffile->ffe);
@@ -589,7 +570,6 @@ void editfilter(int *aborted)
if (*aborted) {
destroyfilterlist(flist);
- clear_flt_tag();
return;
}
strncpy(filename, get_path(T_WORKDIR, ffe->filename),
@@ -614,22 +594,17 @@ void delfilter(int *aborted)
struct ffnode *fltfile;
struct ffnode *fltlist;
- if (!mark_filter_change())
- return;
-
if (loadfilterlist(&fltlist) == 1) {
*aborted = 1;
listfileerr(1);
destroyfilterlist(fltlist);
- clear_flt_tag();
return;
}
pickafilter(fltlist, &fltfile, aborted);
- if (*aborted) {
- clear_flt_tag();
+ if (*aborted)
return;
- }
+
unlink(get_path(T_WORKDIR, fltfile->ffe.filename));
if (fltfile->prev_entry == NULL) {
@@ -646,6 +621,5 @@ void delfilter(int *aborted)
free(fltfile);
save_filterlist(fltlist);
- clear_flt_tag();
*aborted = 0;
}
diff --git a/src/fltmgr.c b/src/fltmgr.c
index 5771f89..ad194ee 100644
--- a/src/fltmgr.c
+++ b/src/fltmgr.c
@@ -21,7 +21,6 @@ fltmgr.c - filter list management routines
#include "dirs.h"
#include "fltdefs.h"
#include "fltmgr.h"
-#include "instances.h"
#include "error.h"
void makestdfiltermenu(struct MENU *menu)
@@ -50,23 +49,6 @@ void genname(unsigned long n, char *m)
sprintf(m, "%lu", n);
}
-int mark_filter_change(void)
-{
- if (!facility_active(OTHIPFLTIDFILE, ""))
- mark_facility(OTHIPFLTIDFILE, "IP filter change", "");
- else {
- tui_error(ANYKEY_MSG,
- "IP protocol data file in use; try again later");
- return 0;
- }
- return 1;
-}
-
-void clear_flt_tag(void)
-{
- unmark_facility(OTHIPFLTIDFILE, "");
-}
-
void listfileerr(int code)
{
if (code == 1)
@@ -224,16 +206,15 @@ void save_filterlist(struct ffnode *fltlist)
if (fd < 0) {
listfileerr(2);
- clear_flt_tag();
return;
}
+
fltfile = fltlist;
while (fltfile != NULL) {
bw = write(fd, &(fltfile->ffe), sizeof(struct filterfileent));
if (bw < 0) {
listfileerr(2);
- clear_flt_tag();
return;
}
ffntemp = fltfile;
diff --git a/src/fltmgr.h b/src/fltmgr.h
index c40b2ff..0477631 100644
--- a/src/fltmgr.h
+++ b/src/fltmgr.h
@@ -30,7 +30,5 @@ void get_filter_description(char *description, int *aborted, char
*pre_edit);
void genname(unsigned long n, char *m);
unsigned long int nametoaddr(char *ascname, int *err);
void listfileerr(int code);
-int mark_filter_change(void);
-void clear_flt_tag(void);
#endif /* IPTRAF_NG_FLTMGR_H */
diff --git a/src/fltselect.c b/src/fltselect.c
index 698c5bd..4be6243 100644
--- a/src/fltselect.c
+++ b/src/fltselect.c
@@ -23,7 +23,6 @@ fltselect.c - a menu-based module that allows selection of
#include "ipfilter.h"
#include "deskman.h"
#include "attrs.h"
-#include "instances.h"
struct filterstate ofilter;
@@ -192,15 +191,6 @@ void savefilters(void)
int pfd;
int bw;
- if (!facility_active(FLTIDFILE, ""))
- mark_facility(FLTIDFILE, "Filter configuration change", "");
- else {
- tui_error(ANYKEY_MSG,
- "Filter state file currently in use;"
- " try again later");
- return;
- }
-
pfd =
open(FLTSTATEFILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
bw = write(pfd, &ofilter, sizeof(struct filterstate));
@@ -210,5 +200,4 @@ void savefilters(void)
close(pfd);
- unmark_facility(FLTIDFILE, "");
}
diff --git a/src/hostmon.c b/src/hostmon.c
index b807926..de72163 100644
--- a/src/hostmon.c
+++ b/src/hostmon.c
@@ -24,7 +24,6 @@ Discovers LAN hosts and displays packet statistics for them
#include "timer.h"
#include "landesc.h"
#include "options.h"
-#include "instances.h"
#include "logvars.h"
#include "promisc.h"
#include "error.h"
@@ -774,35 +773,19 @@ void hostmon(time_t facilitytime, char *ifptr)
PANEL *sortpanel;
int keymode = 0;
- int instance_id;
-
int fd;
- if (!facility_active(LANMONIDFILE, ifptr))
- mark_facility(LANMONIDFILE, "LAN monitor", ifptr);
- else {
- write_error("LAN station monitor already running on %s",
- gen_iface_msg(ifptr));
+ if (ifptr && !dev_up(ifptr)) {
+ err_iface_down();
return;
}
- if (ifptr != NULL) {
- if (!dev_up(ifptr)) {
- err_iface_down();
- unmark_facility(LANMONIDFILE, ifptr);
- return;
- }
- }
-
LIST_HEAD(promisc);
- if (options.promisc && first_active_facility()) {
+ if (options.promisc) {
promisc_init(&promisc, ifptr);
promisc_set_list(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, 1);
- instance_id = adjust_instance_count(LANMONCOUNTFILE, 1);
-
hostmonhelp();
initethtab(&table);
@@ -816,7 +799,7 @@ void hostmon(time_t facilitytime, char *ifptr)
if (logging) {
if (strcmp(current_logfile, "") == 0) {
strncpy(current_logfile,
- gen_instance_logname(LANLOG, instance_id), 80);
+ gen_instance_logname(LANLOG, getpid()), 80);
if (!daemonized)
input_logfile(current_logfile, &logging);
@@ -1027,14 +1010,11 @@ err_close:
close(fd);
err:
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, -1);
- adjust_instance_count(LANMONCOUNTFILE, -1);
-
if (logging) {
signal(SIGUSR1, SIG_DFL);
writeethlog(table.head, time(NULL) - statbegin, logfile);
@@ -1055,6 +1035,5 @@ err:
free_eth_desc(elist);
free_eth_desc(flist);
- unmark_facility(LANMONIDFILE, ifptr);
strcpy(current_logfile, "");
}
diff --git a/src/ifstats.c b/src/ifstats.c
index f8943bc..e8eda20 100644
--- a/src/ifstats.c
+++ b/src/ifstats.c
@@ -24,7 +24,6 @@ ifstats.c - the interface statistics module
#include "attrs.h"
#include "serv.h"
#include "timer.h"
-#include "instances.h"
#include "logvars.h"
#include "promisc.h"
#include "error.h"
@@ -451,30 +450,20 @@ void ifstats(time_t facilitytime)
time_t startlog = 0;
struct timeval updtime;
- if (!facility_active(GSTATIDFILE, ""))
- mark_facility(GSTATIDFILE, "general interface statistics", "");
- else {
- write_error("General interface stats already active in another process");
- return;
- }
-
initiflist(&(table.head));
- if (table.head == NULL) {
+ if (!table.head) {
no_ifaces_error();
- unmark_facility(GSTATIDFILE, "");
return;
}
initiftab(&table);
LIST_HEAD(promisc);
- if (options.promisc && first_active_facility()) {
+ if (options.promisc) {
promisc_init(&promisc, NULL);
promisc_set_list(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, 1);
-
if (logging) {
if (strcmp(current_logfile, "") == 0) {
strcpy(current_logfile, GSTATLOG);
@@ -626,13 +615,11 @@ void ifstats(time_t facilitytime)
close(fd);
err:
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, -1);
-
del_panel(table.statpanel);
delwin(table.statwin);
del_panel(table.borderpanel);
@@ -649,7 +636,6 @@ err:
}
destroyiflist(table.head);
pkt_cleanup();
- unmark_facility(GSTATIDFILE, "");
strcpy(current_logfile, "");
}
diff --git a/src/instances.c b/src/instances.c
deleted file mode 100644
index a5b3af5..0000000
--- a/src/instances.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* For terms of usage/redistribution/modification see the LICENSE file */
-/* For authors and contributors see the AUTHORS file */
-
-/***
-
-instances.c - handler routines for multiple IPTraf instances
-
-***/
-
-#include "iptraf-ng-compat.h"
-
-#include "error.h"
-#include "dirs.h"
-#include "instances.h"
-
-static void gen_lockfile_name(char *tagfile, char *iface, char *result)
-{
- if (iface == NULL)
- snprintf(result, 64, "%s.all", tagfile);
- else
- snprintf(result, 64, "%s.%s", tagfile, iface);
-}
-
-void mark_facility(char *tagfile, char *facility, char *iface)
-{
- int fd;
- char lockfile[64];
-
- gen_lockfile_name(tagfile, iface, lockfile);
- fd = open(lockfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
- if (fd < 0)
- write_error("Warning: unable to lock %s on %s", facility, iface);
- close(fd);
-}
-
-void unmark_facility(char *tagfile, char *iface)
-{
- char lockfile[64];
-
- gen_lockfile_name(tagfile, iface, lockfile);
- unlink(lockfile);
-}
-
-int facility_active(char *tagfile, char *iface)
-{
- int fd;
- char lockfile[64];
-
- gen_lockfile_name(tagfile, iface, lockfile);
- fd = open(lockfile, O_RDONLY);
-
- if (fd < 0)
- return 0;
- else {
- close(fd);
- return 1;
- }
-}
-
-/*
- * Increments or decrements the process count
- */
-
-int adjust_instance_count(char *countfile, int inc)
-{
- int fd;
- int proccount = 0;
- int brw;
-
- fd = open(countfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- brw = read(fd, &proccount, sizeof(int));
- if ((brw == 0) || (brw == -1))
- proccount = 0;
-
- proccount += inc;
-
- if (proccount < 0)
- proccount = 0;
-
- lseek(fd, 0, SEEK_SET);
- brw = write(fd, &proccount, sizeof(int));
- close(fd);
-
- return proccount;
-}
-
-int get_instance_count(char *countfile)
-{
- int fd;
- int proccount = 0;
- int br;
-
- fd = open(countfile, O_RDONLY);
- br = read(fd, &proccount, sizeof(int));
- if ((br == 0) || (br == -1))
- proccount = 0;
-
- close(fd);
- return proccount;
-}
-
-/*
- * Returns TRUE if this is the last instance, and is therefore responsible
- * for restoring the promicuous states saved by the first instance.
- *
- * Man, this is getting more complex by the minute :)
- */
-
-int is_last_instance(void)
-{
- int fd;
- int proccount = 0;
- int br;
-
- fd = open(PROCCOUNTFILE, O_RDONLY);
- br = read(fd, &proccount, sizeof(int));
- close(fd);
- return ((proccount == 1) || (br < 0) || fd < 0);
-}
-
-/*
- * Returns TRUE if no facilities are currently running in other instances of
- * IPTraf. Call this before the first invocation of adjust_process_count(1)
- */
-
-int first_active_facility(void)
-{
- int fd;
- int proccount = 0;
- int br;
-
- fd = open(PROCCOUNTFILE, O_RDONLY);
- br = read(fd, &proccount, sizeof(int));
- close(fd);
- return ((proccount == 0) || (br < 0) || (fd < 0));
-}
diff --git a/src/instances.h b/src/instances.h
deleted file mode 100644
index 47d1080..0000000
--- a/src/instances.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef IPTRAF_NG_INSTANCES_H
-#define IPTRAF_NG_INSTANCES_H
-
-/***
-
-instances.h - header file for instances.c
-
-***/
-
-void mark_facility(char *tagfile, char *facility, char *ifptr);
-void unmark_facility(char *tagfile, char *ifptr);
-int facility_active(char *tagfile, char *ifptr);
-int adjust_instance_count(char *countfile, int inc);
-int get_instance_count(char *countfile);
-int is_last_instance(void);
-int first_active_facility(void);
-
-#endif /* IPTRAF_NG_INSTANCES_H */
diff --git a/src/iptraf-ng-compat.h b/src/iptraf-ng-compat.h
index 1e1ef3f..0dfc4dc 100644
--- a/src/iptraf-ng-compat.h
+++ b/src/iptraf-ng-compat.h
@@ -89,7 +89,6 @@
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
-extern int is_first_instance; /* in iptraf.c */
extern int daemonized;
extern int exitloop;
diff --git a/src/iptraf.c b/src/iptraf.c
index 65e9f2c..15789a9 100644
--- a/src/iptraf.c
+++ b/src/iptraf.c
@@ -52,7 +52,6 @@ struct cmd_struct {
int exitloop = 0;
int daemonized = 0;
int facility_running = 0;
-int is_first_instance;
static void press_enter_to_continue(void)
{
@@ -246,33 +245,6 @@ static void program_interface(void)
tx_destroymenu(&menu);
}
-static int first_instance(void)
-{
- int fd;
-
- fd = open(IPTIDFILE, O_RDONLY);
-
- if (fd < 0)
- return !0;
- else {
- close(fd);
- return 0;
- }
-}
-
-static void mark_first_instance(void)
-{
- int fd;
-
- fd = open(IPTIDFILE, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
- if (fd < 0) {
- fprintf(stderr, "\nWarning: unable to tag this process\r\n");
- press_enter_to_continue();
- return;
- }
- close(fd);
-}
-
static const char *const iptraf_ng_usage[] = {
IPTRAF_NAME " [options]",
IPTRAF_NAME " [options] -B [-i <iface> | -d <iface> | -s <iface>
| -z <iface> | -l <iface> | -g]",
@@ -419,8 +391,6 @@ int main(int argc, char **argv)
current_log_interval = I_opt;
#endif
- is_first_instance = first_instance();
-
if ((getenv("TERM") == NULL) && (!daemonized))
die("Your TERM variable is not set.\n"
"Please set it to an appropriate value");
@@ -460,8 +430,6 @@ int main(int argc, char **argv)
die("This program requires a screen size of at least 80 columns by 24
lines\n" "Please resize your window");
}
- mark_first_instance();
-
signal(SIGTSTP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
@@ -533,8 +501,5 @@ int main(int argc, char **argv)
doupdate();
endwin();
- if (is_first_instance)
- unlink(IPTIDFILE);
-
return (0);
}
diff --git a/src/itrafmon.c b/src/itrafmon.c
index a2cbc52..670ab6d 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -28,7 +28,6 @@ itrafmon.c - the IP traffic monitor module
#include "dirs.h"
#include "timer.h"
#include "ipfrag.h"
-#include "instances.h"
#include "logvars.h"
#include "itrafmon.h"
#include "sockaddr.h"
@@ -601,7 +600,6 @@ void ipmon(time_t facilitytime, char *ifptr)
int rvnfd = 0;
- int instance_id;
int revlook = options.revlook;
int wasempty = 1;
@@ -611,34 +609,17 @@ void ipmon(time_t facilitytime, char *ifptr)
* Mark this instance of the traffic monitor
*/
- if (!facility_active(IPMONIDFILE, ifptr))
- mark_facility(IPMONIDFILE, "IP traffic monitor", ifptr);
- else {
- write_error("IP Traffic Monitor already listening on %s",
gen_iface_msg(ifptr));
+ if (ifptr && !dev_up(ifptr)) {
+ err_iface_down();
return;
}
- if (ifptr != NULL) {
- if (!dev_up(ifptr)) {
- err_iface_down();
- unmark_facility(IPMONIDFILE, ifptr);
- return;
- }
- }
-
LIST_HEAD(promisc);
- if (options.promisc && first_active_facility()) {
+ if (options.promisc) {
promisc_init(&promisc, ifptr);
promisc_set_list(&promisc);
}
- /*
- * Adjust instance counters
- */
-
- adjust_instance_count(PROCCOUNTFILE, 1);
- instance_id = adjust_instance_count(ITRAFMONCOUNTFILE, 1);
-
init_tcp_table(&table);
init_othp_table(&othptbl);
@@ -679,7 +660,7 @@ void ipmon(time_t facilitytime, char *ifptr)
if (logging) {
if (strcmp(current_logfile, "") == 0) {
strncpy(current_logfile,
- gen_instance_logname(IPMONLOG, instance_id),
+ gen_instance_logname(IPMONLOG, getpid()),
80);
if (!daemonized)
@@ -1174,8 +1155,7 @@ void ipmon(time_t facilitytime, char *ifptr)
err_close:
close(fd);
err:
- if (get_instance_count(ITRAFMONCOUNTFILE) <= 1)
- killrvnamed();
+ killrvnamed();
if (options.servnames)
endservent();
@@ -1183,7 +1163,7 @@ err:
endprotoent();
close_rvn_socket(rvnfd);
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
@@ -1213,8 +1193,4 @@ err:
fclose(logfile);
strcpy(current_logfile, "");
}
-
- adjust_instance_count(PROCCOUNTFILE, -1);
- adjust_instance_count(ITRAFMONCOUNTFILE, -1);
- unmark_facility(IPMONIDFILE, ifptr);
}
diff --git a/src/options.c b/src/options.c
index d0ead45..a1cd4f8 100644
--- a/src/options.c
+++ b/src/options.c
@@ -21,7 +21,6 @@ options.c - implements the configuration section of the utility
#include "landesc.h"
#include "promisc.h"
#include "dirs.h"
-#include "instances.h"
#define ALLOW_ZERO 1
#define DONT_ALLOW_ZERO 0
@@ -262,13 +261,6 @@ void setoptions(void)
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);
diff --git a/src/pktsize.c b/src/pktsize.c
index b54d79b..eecb2e5 100644
--- a/src/pktsize.c
+++ b/src/pktsize.c
@@ -21,7 +21,6 @@ pktsize.c - the packet size breakdown facility
#include "pktsize.h"
#include "options.h"
#include "timer.h"
-#include "instances.h"
#include "log.h"
#include "logvars.h"
#include "promisc.h"
@@ -163,13 +162,6 @@ void packet_size_breakdown(char *ifname, time_t facilitytime)
int fd;
- if (!facility_active(PKTSIZEIDFILE, ifname))
- mark_facility(PKTSIZEIDFILE, "Packet size breakdown", ifname);
- else {
- write_error("Packet sizes already being monitored on %s", ifname);
- return;
- }
-
if (!dev_up(ifname)) {
err_iface_down();
goto err_unmark;
@@ -240,13 +232,11 @@ void packet_size_breakdown(char *ifname, time_t facilitytime)
now = starttime = startlog = timeint = tv.tv_sec;
LIST_HEAD(promisc);
- if (first_active_facility() && options.promisc) {
+ if (options.promisc) {
promisc_init(&promisc, ifname);
promisc_set_list(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, 1);
-
fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if(fd == -1) {
write_error("Unable to obtain monitoring socket");
@@ -333,18 +323,15 @@ err:
fclose(logfile);
}
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, -1);
-
del_panel(panel);
delwin(win);
del_panel(borderpanel);
delwin(borderwin);
err_unmark:
- unmark_facility(PKTSIZEIDFILE, ifname);
strcpy(current_logfile, "");
}
diff --git a/src/serv.c b/src/serv.c
index 84e4e94..1bef335 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -27,7 +27,6 @@ serv.c - TCP/UDP port statistics module
#include "timer.h"
#include "promisc.h"
#include "options.h"
-#include "instances.h"
#include "packet.h"
#include "logvars.h"
#include "error.h"
@@ -791,33 +790,19 @@ void servmon(char *ifname, time_t facilitytime)
struct porttab *ports;
- /*
- * Mark this facility
- */
-
- if (!facility_active(TCPUDPIDFILE, ifname))
- mark_facility(TCPUDPIDFILE, "TCP/UDP monitor", ifname);
- else {
- write_error("TCP/UDP monitor already running on %s", ifname);
- return;
- }
-
if (!dev_up(ifname)) {
err_iface_down();
- unmark_facility(TCPUDPIDFILE, ifname);
return;
}
loadaddports(&ports);
LIST_HEAD(promisc);
- if (first_active_facility() && options.promisc) {
+ if (options.promisc) {
promisc_init(&promisc, ifname);
promisc_set_list(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, 1);
-
initportlist(&list);
statwin = newwin(1, COLS, LINES - 2, 0);
statpanel = new_panel(statwin);
@@ -1087,20 +1072,17 @@ err:
if (options.servnames)
endservent();
- if (options.promisc && is_last_instance()) {
+ if (options.promisc) {
promisc_restore_list(&promisc);
promisc_destroy(&promisc);
}
- adjust_instance_count(PROCCOUNTFILE, -1);
-
del_panel(list.panel);
delwin(list.win);
del_panel(list.borderpanel);
delwin(list.borderwin);
del_panel(statpanel);
delwin(statwin);
- unmark_facility(TCPUDPIDFILE, ifname);
update_panels();
doupdate();
destroyportlist(&list);
--
1.7.11.5