From a65619daba35e782e6b207fb72d2a6bb06172d4a Mon Sep 17 00:00:00 2001 From: Nicolas Thill Date: Tue, 4 Oct 2005 20:45:16 +0000 Subject: [PATCH] add iptraf (thanks to Thomas Reifferscheid) SVN-Revision: 2048 --- openwrt/package/Config.in | 1 + openwrt/package/Makefile | 2 + openwrt/package/iptraf/Config.in | 12 + openwrt/package/iptraf/Makefile | 44 ++ openwrt/package/iptraf/ipkg/iptraf.control | 7 + .../patches/iptraf-2.7.0-cross_compile.patch | 29 + .../iptraf/patches/iptraf-2.7.0-ifaces.patch | 549 ++++++++++++++++++ 7 files changed, 644 insertions(+) create mode 100644 openwrt/package/iptraf/Config.in create mode 100644 openwrt/package/iptraf/Makefile create mode 100644 openwrt/package/iptraf/ipkg/iptraf.control create mode 100644 openwrt/package/iptraf/patches/iptraf-2.7.0-cross_compile.patch create mode 100644 openwrt/package/iptraf/patches/iptraf-2.7.0-ifaces.patch diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in index ce56d4da65..1991e9f083 100644 --- a/openwrt/package/Config.in +++ b/openwrt/package/Config.in @@ -65,6 +65,7 @@ source "package/htpdate/Config.in" source "package/iproute2/Config.in" source "package/iperf/Config.in" source "package/ipset/Config.in" +source "package/iptraf/Config.in" source "package/kismet/Config.in" source "package/l2tpd/Config.in" source "package/lighttpd/Config.in" diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile index 8b41cf6448..cbb1bf4e6a 100644 --- a/openwrt/package/Makefile +++ b/openwrt/package/Makefile @@ -56,6 +56,7 @@ package-$(BR2_PACKAGE_IPKG) += ipkg package-$(BR2_PACKAGE_IPROUTE2) += iproute2 package-$(BR2_PACKAGE_IPSET) += ipset package-$(BR2_PACKAGE_IPTABLES) += iptables +package-$(BR2_PACKAGE_IPTRAF) += iptraf package-$(BR2_PACKAGE_IRSSI) += irssi package-$(BR2_COMPILE_JPEG) += jpeg package-$(BR2_PACKAGE_KISMET) += kismet @@ -217,6 +218,7 @@ gmediaserver-compile: id3lib-compile libupnp-compile gnutls-compile: libgcrypt-compile opencdk-compile libtasn1-compile id3lib-compile: uclibc++-compile zlib-compile irssi-compile: glib-compile ncurses-compile +iptraf-compile: ncurses-compile hostapd-compile: openssl-compile kismet-compile: uclibc++-compile libpcap-compile ncurses-compile less-compile: ncurses-compile diff --git a/openwrt/package/iptraf/Config.in b/openwrt/package/iptraf/Config.in new file mode 100644 index 0000000000..e814503cd0 --- /dev/null +++ b/openwrt/package/iptraf/Config.in @@ -0,0 +1,12 @@ +config BR2_PACKAGE_IPTRAF + tristate "iptraf - A console-based network monitoring program" + default m if CONFIG_DEVEL + help + IPTraf is a console-based network statistics utility for Linux. It gathers + a variety of figures such as TCP connection packet and byte counts, + interface statistics and activity indicators, TCP/UDP traffic breakdowns, + and LAN station packet and byte counts. + + http://iptraf.seul.org/ + + diff --git a/openwrt/package/iptraf/Makefile b/openwrt/package/iptraf/Makefile new file mode 100644 index 0000000000..3837ec8566 --- /dev/null +++ b/openwrt/package/iptraf/Makefile @@ -0,0 +1,44 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=iptraf +PKG_VERSION:=2.7.0 +PKG_RELEASE:=1 +PKG_MD5SUM:= + +PKG_SOURCE_URL:=ftp://iptraf.seul.org/pub/iptraf/ \ + ftp://the.wiretapped.net/pub/security/network-monitoring/iptraf/ +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_CAT:=zcat + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install + +include $(TOPDIR)/package/rules.mk + +$(eval $(call PKG_template,IPTRAF,iptraf,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH))) + +$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared + touch $@ + +$(PKG_BUILD_DIR)/.built: + $(MAKE) -C $(PKG_BUILD_DIR)/src \ + $(TARGET_CONFIGURE_OPTS) \ + CFLAGS="$(TARGET_CFLAGS)" \ + DEBUG="" \ + INCLUDEDIR="-I../support -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \ + LDOPTS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \ + PLATFORM="-DPLATFORM=\\\"Linux/$(ARCH)\\\"" \ + TARGET="/usr/bin" \ + WORKDIR="/var/lib/iptraf" \ + all + touch $@ + +$(IPKG_IPTRAF): + install -d -m0755 $(IDIR_IPTRAF)/usr/bin + install -m0755 $(PKG_BUILD_DIR)/src/iptraf $(IDIR_IPTRAF)/usr/bin/ + $(RSTRIP) $(IDIR_IPTRAF) + $(IPKG_BUILD) $(IDIR_IPTRAF) $(PACKAGE_DIR) + +mostlyclean: + -$(MAKE) -C $(PKG_BUILD_DIR) clean + rm -f $(PKG_BUILD_DIR)/.built diff --git a/openwrt/package/iptraf/ipkg/iptraf.control b/openwrt/package/iptraf/ipkg/iptraf.control new file mode 100644 index 0000000000..64ce9a6a55 --- /dev/null +++ b/openwrt/package/iptraf/ipkg/iptraf.control @@ -0,0 +1,7 @@ +Package: iptraf +Priority: optional +Section: net +Maintainer: OpenWrt Developers Team , Thomas Reifferscheid +Source: http://openwrt.org/cgi-bin/viewcvs.cgi/openwrt/package/iptraf/ +Depends: libncurses +Description: A console-based network monitoring program. diff --git a/openwrt/package/iptraf/patches/iptraf-2.7.0-cross_compile.patch b/openwrt/package/iptraf/patches/iptraf-2.7.0-cross_compile.patch new file mode 100644 index 0000000000..6c0119df73 --- /dev/null +++ b/openwrt/package/iptraf/patches/iptraf-2.7.0-cross_compile.patch @@ -0,0 +1,29 @@ +diff -ruN iptraf-2.7.0-old/support/Makefile iptraf-2.7.0-new/support/Makefile +--- iptraf-2.7.0-old/support/Makefile 2001-11-27 09:37:11.000000000 +0100 ++++ iptraf-2.7.0-new/support/Makefile 2005-10-03 18:40:40.000000000 +0200 +@@ -3,16 +3,21 @@ + OBJS = input.o menurt.o listbox.o winops.o labels.o \ + msgboxes.o + ++AR=ar ++CC=cc ++RANLIB=ranlib ++CFLAGS= -O2 -g -fPIC ++ + all: libtextbox.a + + libtextbox.a: $(OBJS) + rm -rf libtextbox.a +- ar cq libtextbox.a $(OBJS) +- ranlib libtextbox.a +-# gcc -shared -o libtextbox.so $(OBJS) ++ $(AR) cq libtextbox.a $(OBJS) ++ $(RANLIB) libtextbox.a ++# $(CC) -shared -o libtextbox.so $(OBJS) + + %.o: %.c *.h +- gcc -O2 -g -Wall -fPIC $(INCLUDEDIR) -c -o $*.o $< ++ $(CC) $(CFLAGS) -Wall $(INCLUDEDIR) -c -o $*.o $< + + clean: + rm -rf *.o *~ libtextbox.a libtextbox.so diff --git a/openwrt/package/iptraf/patches/iptraf-2.7.0-ifaces.patch b/openwrt/package/iptraf/patches/iptraf-2.7.0-ifaces.patch new file mode 100644 index 0000000000..fdf09a2013 --- /dev/null +++ b/openwrt/package/iptraf/patches/iptraf-2.7.0-ifaces.patch @@ -0,0 +1,549 @@ +diff -ruN iptraf-2.7.0-old/src/dirs.h iptraf-2.7.0-new/src/dirs.h +--- iptraf-2.7.0-old/src/dirs.h 2001-05-03 12:44:11.000000000 +0200 ++++ iptraf-2.7.0-new/src/dirs.h 2005-10-04 21:51:26.000000000 +0200 +@@ -148,11 +148,10 @@ + #define PORTFILE get_path(T_WORKDIR, "ports.dat") + + /* +- * The Ethernet and FDDI host description files ++ * The Ethernet host description files + */ + + #define ETHFILE get_path(T_WORKDIR, "ethernet.desc") +-#define FDDIFILE get_path(T_WORKDIR, "fddi.desc") + + /* + * The rvnamed program file +diff -ruN iptraf-2.7.0-old/src/hostmon.c iptraf-2.7.0-new/src/hostmon.c +--- iptraf-2.7.0-old/src/hostmon.c 2002-04-16 04:15:25.000000000 +0200 ++++ iptraf-2.7.0-new/src/hostmon.c 2005-10-04 21:52:02.000000000 +0200 +@@ -30,7 +30,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -294,8 +293,6 @@ + wprintw(table->tabwin, "Ethernet"); + else if (entry->un.desc.linktype == LINK_PLIP) + wprintw(table->tabwin, "PLIP"); +- else if (entry->un.desc.linktype == LINK_FDDI) +- wprintw(table->tabwin, "FDDI"); + + wprintw(table->tabwin, " HW addr: %s", entry->un.desc.ascaddr); + +@@ -771,7 +768,6 @@ + + initethtab(&table, options->actmode); + loaddesclist(&elist, LINK_ETHERNET, WITHETCETHERS); +- loaddesclist(&flist, LINK_FDDI, WITHETCETHERS); + + if (logging) { + if (strcmp(current_logfile, "") == 0) +@@ -854,7 +850,7 @@ + } + linktype = getlinktype(fromaddr.sll_hatype, ifname, -1, NULL); + +- if ((linktype == LINK_ETHERNET) || (linktype == LINK_FDDI) ++ if ((linktype == LINK_ETHERNET) + || (linktype == LINK_PLIP) || (linktype == LINK_TR)) { + if (fromaddr.sll_protocol == htons(ETH_P_IP)) + is_ip = 1; +@@ -871,12 +867,6 @@ + memcpy(scratch_daddr, ((struct ethhdr *) buf)->h_dest, + ETH_ALEN); + list = &elist; +- } else if (linktype == LINK_FDDI) { +- memcpy(scratch_saddr, ((struct fddihdr *) buf)->saddr, +- FDDI_K_ALEN); +- memcpy(scratch_daddr, ((struct fddihdr *) buf)->daddr, +- FDDI_K_ALEN); +- list = &flist; + } else if (linktype == LINK_TR) { + memcpy(scratch_saddr, ((struct trh_hdr *) buf)->saddr, + TR_ALEN); +diff -ruN iptraf-2.7.0-old/src/ifaces.c iptraf-2.7.0-new/src/ifaces.c +--- iptraf-2.7.0-old/src/ifaces.c 2002-05-08 11:43:27.000000000 +0200 ++++ iptraf-2.7.0-new/src/ifaces.c 2005-10-04 21:54:00.000000000 +0200 +@@ -37,9 +37,9 @@ + extern int daemonized; + + char ifaces[][6] = +- { "lo", "eth", "sl", "ppp", "ippp", "plip", "fddi", "isdn", "dvb", ++ { "lo", "eth", "sl", "ppp", "ippp", "plip", "isdn", "dvb", + "pvc", "hdlc", "ipsec", "sbni", "tr", "wvlan", "wlan", "sm2", "sm3", +- "pent", "lec" }; ++ "pent", "lec", "vlan" }; + + char *ltrim(char *buf) + { +diff -ruN iptraf-2.7.0-old/src/landesc.c iptraf-2.7.0-new/src/landesc.c +--- iptraf-2.7.0-old/src/landesc.c 2001-11-27 11:23:32.000000000 +0100 ++++ iptraf-2.7.0-new/src/landesc.c 2005-10-04 21:57:33.000000000 +0200 +@@ -82,8 +82,6 @@ + + if (linktype == LINK_ETHERNET) + fd = fopen(ETHFILE, "r"); +- else if (linktype == LINK_FDDI) +- fd = fopen(FDDIFILE, "r"); + + if (fd == NULL) { + return; +@@ -204,8 +202,6 @@ + + if (linktype == LINK_ETHERNET) + fd = fopen(ETHFILE, "w"); +- else if (linktype == LINK_FDDI) +- fd = fopen(FDDIFILE, "w"); + + if (fd < 0) { + etherr(); +diff -ruN iptraf-2.7.0-old/src/links.h iptraf-2.7.0-new/src/links.h +--- iptraf-2.7.0-old/src/links.h 2001-12-18 03:45:16.000000000 +0100 ++++ iptraf-2.7.0-new/src/links.h 2005-10-04 21:57:17.000000000 +0200 +@@ -5,7 +5,6 @@ + #define LINK_LOOPBACK 5 + #define LINK_ISDN_RAWIP 6 + #define LINK_ISDN_CISCOHDLC 7 +-#define LINK_FDDI 8 + #define LINK_FRAD 9 + #define LINK_DLCI 10 + #define LINK_TR 11 +diff -ruN iptraf-2.7.0-old/src/log.c iptraf-2.7.0-new/src/log.c +--- iptraf-2.7.0-old/src/log.c 2002-04-22 05:59:15.000000000 +0200 ++++ iptraf-2.7.0-new/src/log.c 2005-10-04 21:57:51.000000000 +0200 +@@ -465,8 +465,6 @@ + ptmp->un.desc.ascaddr); + else if (ptmp->un.desc.linktype == LINK_PLIP) + fprintf(fd, "\nPLIP address: %s", ptmp->un.desc.ascaddr); +- else if (ptmp->un.desc.linktype == LINK_FDDI) +- fprintf(fd, "\nFDDI address: %s", ptmp->un.desc.ascaddr); + + if (ptmp->un.desc.withdesc) + fprintf(fd, " (%s)", ptmp->un.desc.desc); +diff -ruN iptraf-2.7.0-old/src/options.c iptraf-2.7.0-new/src/options.c +--- iptraf-2.7.0-old/src/options.c 2001-12-28 10:39:15.000000000 +0100 ++++ iptraf-2.7.0-new/src/options.c 2005-10-04 21:58:15.000000000 +0200 +@@ -67,8 +67,6 @@ + tx_additem(menu, NULL, NULL); + tx_additem(menu, " ^E^thernet/PLIP host descriptions...", + "Manages descriptions for Ethernet and PLIP addresses"); +- tx_additem(menu, " ^F^DDI/Token Ring host descriptions...", +- "Manages descriptions for FDDI and FDDI addresses"); + tx_additem(menu, NULL, NULL); + tx_additem(menu, " E^x^it configuration", "Returns to main menu"); + } +@@ -366,9 +364,6 @@ + case 14: + ethdescmgr(LINK_ETHERNET); + break; +- case 15: +- ethdescmgr(LINK_FDDI); +- break; + } + + indicatesetting(row, options, statwin); +diff -ruN iptraf-2.7.0-old/src/othptab.c iptraf-2.7.0-new/src/othptab.c +--- iptraf-2.7.0-old/src/othptab.c 2001-12-28 03:23:59.000000000 +0100 ++++ iptraf-2.7.0-new/src/othptab.c 2005-10-04 21:58:33.000000000 +0200 +@@ -19,7 +19,6 @@ + #include + #include + #include +-#include + #include + #include "arphdr.h" + #include "options.h" +@@ -139,11 +138,6 @@ + new_entry->smacaddr); + convmacaddr(((struct ethhdr *) packet)->h_dest, + new_entry->dmacaddr); +- } else if (linkproto == LINK_FDDI) { +- convmacaddr(((struct fddihdr *) packet)->saddr, +- new_entry->smacaddr); +- convmacaddr(((struct fddihdr *) packet)->daddr, +- new_entry->dmacaddr); + } else if (linkproto == LINK_TR) { + convmacaddr(((struct trh_hdr *) packet)->saddr, + new_entry->smacaddr); +@@ -373,8 +367,7 @@ + strcat(msgstring, scratchpad); + + if ((entry->linkproto == LINK_ETHERNET) || +- (entry->linkproto == LINK_PLIP) || +- (entry->linkproto == LINK_FDDI)) { ++ (entry->linkproto == LINK_PLIP)) { + sprintf(scratchpad, " from %s to %s on %s", + entry->smacaddr, entry->dmacaddr, entry->iface); + +diff -ruN iptraf-2.7.0-old/src/packet.c iptraf-2.7.0-new/src/packet.c +--- iptraf-2.7.0-old/src/packet.c 2002-05-08 11:44:08.000000000 +0200 ++++ iptraf-2.7.0-new/src/packet.c 2005-10-04 21:59:12.000000000 +0200 +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -80,10 +79,10 @@ + case ARPHRD_ETHER: + if (strncmp(ifname, "eth", 3) == 0) + result = LINK_ETHERNET; ++ else if (strncmp(ifname, "vlan", 4) == 0) ++ result = LINK_ETHERNET; + else if (strncmp(ifname, "plip", 4) == 0) + result = LINK_PLIP; +- else if (strncmp(ifname, "fddi", 4) == 0) /* For some Ethernet- */ +- result = LINK_ETHERNET; /* emulated FDDI ifaces */ + else if (strncmp(ifname, "dvb", 3) == 0) + result = LINK_ETHERNET; + else if (strncmp(ifname, "sbni", 4) == 0) +@@ -127,9 +126,6 @@ + case ARPHRD_PPP: + result = LINK_PPP; + break; +- case ARPHRD_FDDI: +- result = LINK_FDDI; +- break; + case ARPHRD_IEEE802: + case ARPHRD_IEEE802_TR: + result = LINK_TR; +@@ -179,19 +175,6 @@ + *packet = tpacket + 4; + *readlen -= 4; + break; +- case LINK_FDDI: +- *packet = tpacket + sizeof(struct fddihdr); +- *readlen -= sizeof(struct fddihdr); +- +- /* +- * Move IP data into an aligned buffer. 96 bytes should be sufficient +- * for IP and TCP headers with reasonable numbers of options and some +- * data. +- */ +- +- memmove(aligned_buf, *packet, min(SNAPSHOT_LEN, *readlen)); +- *packet = aligned_buf; +- break; + case LINK_TR: + /* + * Token Ring patch supplied by Tomas Dvorak +diff -ruN iptraf-2.7.0-old/src/promisc.c iptraf-2.7.0-new/src/promisc.c +--- iptraf-2.7.0-old/src/promisc.c 2002-01-16 02:51:03.000000000 +0100 ++++ iptraf-2.7.0-new/src/promisc.c 2005-10-04 22:05:25.000000000 +0200 +@@ -81,7 +81,7 @@ + */ + + if ((strncmp(buf, "eth", 3) == 0) || +- (strncmp(buf, "fddi", 4) == 0) || ++ (strncmp(buf, "vlan", 4) == 0) || + (strncmp(ptmp->params.ifname, "wvlan", 4) == 0) || + (strncmp(ptmp->params.ifname, "lec", 3) == 0) || + (accept_unsupported_interfaces)) { +@@ -194,7 +194,7 @@ + + while (ptmp != NULL) { + if (((strncmp(ptmp->params.ifname, "eth", 3) == 0) || +- (strncmp(ptmp->params.ifname, "fddi", 4) == 0) || ++ (strncmp(ptmp->params.ifname, "vlan", 4) == 0) || + (strncmp(ptmp->params.ifname, "wvlan", 4) == 0) || + (strncmp(ptmp->params.ifname, "lec", 3) == 0)) && + (ptmp->params.state_valid)) { +diff -ruN iptraf-2.7.0-old/src/promisc.~c iptraf-2.7.0-new/src/promisc.~c +--- iptraf-2.7.0-old/src/promisc.~c 1970-01-01 01:00:00.000000000 +0100 ++++ iptraf-2.7.0-new/src/promisc.~c 2005-10-04 22:00:02.000000000 +0200 +@@ -0,0 +1,238 @@ ++/*** ++ ++promisc.c - handles the promiscuous mode flag for the Ethernet/FDDI ++ interfaces ++ ++Written by Gerard Paul Java ++Copyright (c) Gerard Paul Java 1997, 1998 ++ ++This module contains functions that manage the promiscuous states of ++the interfaces. ++ ++This software is open source; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed WITHOUT ANY WARRANTY; without even the ++implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++See the GNU General Public License in the included COPYING file for ++details. ++ ++***/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "ifstats.h" ++#include "ifaces.h" ++#include "error.h" ++#include "promisc.h" ++#include "dirs.h" ++ ++#define PROMISC_MSG_MAX 80 ++ ++extern int daemonized; ++extern int accept_unsupported_interfaces; ++ ++void init_promisc_list(struct promisc_states **list) ++{ ++ FILE *fd; ++ int ifd; ++ char buf[8]; ++ struct promisc_states *ptmp; ++ struct promisc_states *tail = NULL; ++ struct ifreq ifr; ++ int istat; ++ char err_msg[80]; ++ ++ ifd = socket(PF_INET, SOCK_DGRAM, 0); ++ ++ *list = NULL; ++ fd = open_procnetdev(); ++ ++ do { ++ get_next_iface(fd, buf); ++ ++ if (strcmp(buf, "") != 0) { ++ ptmp = malloc(sizeof(struct promisc_states)); ++ strcpy(ptmp->params.ifname, buf); ++ ++ if (*list == NULL) { ++ *list = ptmp; ++ } else ++ tail->next_entry = ptmp; ++ ++ tail = ptmp; ++ ptmp->next_entry = NULL; ++ ++ /* ++ * Retrieve and save interface flags ++ */ ++ ++ if ((strncmp(buf, "eth", 3) == 0) || ++ (strncmp(buf, "vlan", 4) == 0) || ++ (strncmp(buf, "fddi", 4) == 0) || ++ (strncmp(ptmp->params.ifname, "wvlan", 4) == 0) || ++ (strncmp(ptmp->params.ifname, "lec", 3) == 0) || ++ (accept_unsupported_interfaces)) { ++ strcpy(ifr.ifr_name, buf); ++ ++ istat = ioctl(ifd, SIOCGIFFLAGS, &ifr); ++ ++ if (istat < 0) { ++ sprintf(err_msg, ++ "Unable to obtain interface parameters for %s", ++ buf); ++ write_error(err_msg, daemonized); ++ ptmp->params.state_valid = 0; ++ } else { ++ ptmp->params.saved_state = ifr.ifr_flags; ++ ptmp->params.state_valid = 1; ++ } ++ } ++ } ++ } while (strcmp(buf, "") != 0); ++} ++ ++/* ++ * Save interfaces and their states to a temporary file. Used only by the ++ * first IPTraf instance. Needed in case there are subsequent, simultaneous ++ * instances of IPTraf, which may still need promiscuous mode even after ++ * the first instance exits. These subsequent instances will need to restore ++ * the promiscuous state from this file. ++ */ ++ ++void save_promisc_list(struct promisc_states *list) ++{ ++ int fd; ++ struct promisc_states *ptmp = list; ++ ++ fd = open(PROMISCLISTFILE, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); ++ ++ if (fd < 0) { ++ write_error("Unable to save interface flags", daemonized); ++ return; ++ } ++ ++ while (ptmp != NULL) { ++ write(fd, &(ptmp->params), sizeof(struct promisc_params)); ++ ptmp = ptmp->next_entry; ++ } ++ ++ close(fd); ++} ++ ++/* ++ * Load promiscuous states into list ++ */ ++ ++void load_promisc_list(struct promisc_states **list) ++{ ++ int fd; ++ struct promisc_states *ptmp = NULL; ++ struct promisc_states *tail = NULL; ++ int br; ++ ++ fd = open(PROMISCLISTFILE, O_RDONLY); ++ ++ if (fd < 0) { ++ write_error("Unable to retrieve saved interface flags", ++ daemonized); ++ *list = NULL; ++ return; ++ } ++ ++ do { ++ ptmp = malloc(sizeof(struct promisc_states)); ++ br = read(fd, &(ptmp->params), sizeof(struct promisc_params)); ++ ++ if (br > 0) { ++ if (tail != NULL) ++ tail->next_entry = ptmp; ++ else ++ *list = ptmp; ++ ++ ptmp->next_entry = NULL; ++ tail = ptmp; ++ } else ++ free(ptmp); ++ } while (br > 0); ++ ++ close(fd); ++} ++ ++/* ++ * Set/restore interface promiscuous mode. ++ */ ++ ++void srpromisc(int mode, struct promisc_states *list) ++{ ++ int fd; ++ struct ifreq ifr; ++ struct promisc_states *ptmp; ++ int istat; ++ char fullmsg[PROMISC_MSG_MAX]; ++ ++ ptmp = list; ++ ++ fd = socket(PF_INET, SOCK_DGRAM, 0); ++ ++ if (fd < 0) { ++ write_error("Unable to open socket for flag change", daemonized); ++ return; ++ } ++ ++ while (ptmp != NULL) { ++ if (((strncmp(ptmp->params.ifname, "eth", 3) == 0) || ++ (strncmp(ptmp->params.ifname, "vlan", 4) == 0) || ++ (strncmp(ptmp->params.ifname, "wvlan", 4) == 0) || ++ (strncmp(ptmp->params.ifname, "lec", 3) == 0)) && ++ (ptmp->params.state_valid)) { ++ ++ strcpy(ifr.ifr_name, ptmp->params.ifname); ++ ++ if (mode) ++ ifr.ifr_flags = ptmp->params.saved_state | IFF_PROMISC; ++ else ++ ifr.ifr_flags = ptmp->params.saved_state; ++ ++ istat = ioctl(fd, SIOCSIFFLAGS, &ifr); ++ ++ if (istat < 0) { ++ sprintf(fullmsg, "Promisc change failed for %s", ++ ptmp->params.ifname); ++ write_error(fullmsg, daemonized); ++ } ++ } ++ ptmp = ptmp->next_entry; ++ } ++ ++ close(fd); ++} ++ ++void destroy_promisc_list(struct promisc_states **list) ++{ ++ struct promisc_states *ptmp = *list; ++ struct promisc_states *ctmp; ++ ++ if (ptmp != NULL) ++ ctmp = ptmp->next_entry; ++ ++ while (ptmp != NULL) { ++ free(ptmp); ++ ptmp = ctmp; ++ if (ctmp != NULL) ++ ctmp = ctmp->next_entry; ++ } ++} +diff -ruN iptraf-2.7.0-old/src/rvnamed.c iptraf-2.7.0-new/src/rvnamed.c +--- iptraf-2.7.0-old/src/rvnamed.c 2002-05-02 03:37:34.000000000 +0200 ++++ iptraf-2.7.0-new/src/rvnamed.c 2005-10-04 22:02:47.000000000 +0200 +@@ -48,7 +48,6 @@ + #include + #include + #include "rvnamed.h" +-#include "dirs.h" + + #define NUM_CACHE_ENTRIES 2048 + #define TIME_TARGET_MAX 30 +diff -ruN iptraf-2.7.0-old/src/rvnamed.h iptraf-2.7.0-new/src/rvnamed.h +--- iptraf-2.7.0-old/src/rvnamed.h 2002-05-02 03:36:30.000000000 +0200 ++++ iptraf-2.7.0-new/src/rvnamed.h 2005-10-04 22:03:29.000000000 +0200 +@@ -1,9 +1,10 @@ + #include + #include ++#include "dirs.h" + +-#define CHILDSOCKNAME "/dev/rvndcldcomsk" +-#define PARENTSOCKNAME "/dev/rvndpntcomsk" +-#define IPTSOCKNAME "/dev/rvndiptcomsk" ++#define CHILDSOCKNAME LOCKDIR "/rvndcldcomsk" ++#define PARENTSOCKNAME LOCKDIR "/rvndpntcomsk" ++#define IPTSOCKNAME LOCKDIR "/rvndiptcomsk" + + #define SOCKET_PREFIX "isock" + +diff -ruN iptraf-2.7.0-old/src/tcptable.c iptraf-2.7.0-new/src/tcptable.c +--- iptraf-2.7.0-old/src/tcptable.c 2002-05-08 03:36:27.000000000 +0200 ++++ iptraf-2.7.0-new/src/tcptable.c 2005-10-03 19:25:55.000000000 +0200 +@@ -598,9 +598,6 @@ + if ((linkproto == LINK_ETHERNET) || (linkproto == LINK_PLIP)) { + convmacaddr(((struct ethhdr *) packet)->h_source, + newmacaddr); +- } else if (linkproto == LINK_FDDI) { +- convmacaddr(((struct fddihdr *) packet)->saddr, +- newmacaddr); + } else if (linkproto == LINK_TR) { + convmacaddr(((struct trh_hdr *) packet)->saddr, newmacaddr); + } +diff -ruN iptraf-2.7.0-old/src/tcptable.h iptraf-2.7.0-new/src/tcptable.h +--- iptraf-2.7.0-old/src/tcptable.h 2001-12-28 03:16:39.000000000 +0100 ++++ iptraf-2.7.0-new/src/tcptable.h 2005-10-03 19:26:01.000000000 +0200 +@@ -22,7 +22,6 @@ + #include + #include + #include +-#include + #include + #include + #include