[PATCH] remove ISDN interfaces support
by Vitezslav Samel
It doesn't work and I don't know anyone who needs it and
is willing to debug it.
If there's an interest, we may restore it or rewrite from scratch.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
Documentation/manual.template | 20 -----------
Makefile | 2 -
src/detstats.c | 2 -
src/hostmon.c | 1 -
src/ifaces.c | 8 ----
src/ifaces.h | 1 -
src/ifstats.c | 2 -
src/iptraf-ng-compat.h | 1 -
src/isdntab.c | 73 -----------------------------------------
src/isdntab.h | 20 -----------
src/itrafmon.c | 2 -
src/packet.c | 13 -------
src/packet.h | 2 -
src/pktsize.c | 1 -
src/serv.c | 2 -
15 files changed, 0 insertions(+), 150 deletions(-)
delete mode 100644 src/isdntab.c
delete mode 100644 src/isdntab.h
diff --git a/Documentation/manual.template b/Documentation/manual.template
index 1626331..ba8a1c8 100644
--- a/Documentation/manual.template
+++ b/Documentation/manual.template
@@ -890,26 +890,6 @@ A SLIP interface. <replaceable>n</replaceable> starts from 0.
</para></listitem>
</varlistentry>
<varlistentry>
-<term><filename>ippp<replaceable>n</replaceable></filename></term>
-<listitem><para>
- A synchronous PPP interface using ISDN.
-<replaceable>n</replaceable> starts from 0.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><filename>isdn<replaceable>n</replaceable</filename></term>
-<listitem><para>
- ISDN interfaces can be given arbitrary names, but for them to work
- with IPTraf, they must
- be named <filename>isdn<replaceable>n</replaceable></filename>.
- IPTraf supports synchronous PPP
- (the <filename>ippp<replaceable>n</replaceable></filename>
- interfaces above), raw IP, and Cisco-HDLC encapsulation.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
<term><filename>plip<replaceable>n</replaceable></filename></term>
<listitem><para>
PLIP interfaces. These are point-to-point IP connections using the PC
diff --git a/Makefile b/Makefile
index cefc16d..21ebadc 100644
--- a/Makefile
+++ b/Makefile
@@ -103,7 +103,6 @@ iptraf-h += src/pktsize.h
iptraf-h += src/landesc.h
iptraf-h += src/dirs.h
iptraf-h += src/getpath.h
-iptraf-h += src/isdntab.h
iptraf-h += src/bar.h
iptraf-h += src/options.h
iptraf-h += src/promisc.h
@@ -139,7 +138,6 @@ iptraf-o += src/timer.o
iptraf-o += src/revname.o
iptraf-o += src/pktsize.o
iptraf-o += src/landesc.o
-iptraf-o += src/isdntab.o
iptraf-o += src/options.o
iptraf-o += src/promisc.o
iptraf-o += src/ifaces.o
diff --git a/src/detstats.c b/src/detstats.c
index b707969..8a8eb8c 100644
--- a/src/detstats.c
+++ b/src/detstats.c
@@ -13,7 +13,6 @@ detstats.c - the interface statistics module
#include "counters.h"
#include "ifaces.h"
-#include "isdntab.h"
#include "fltdefs.h"
#include "fltselect.h"
#include "packet.h"
@@ -401,7 +400,6 @@ void detstats(char *iface, const struct OPTIONS *options, time_t facilitytime,
goto err_close;
}
- //isdnfd = -1;
exitloop = 0;
PACKET_INIT(pkt);
diff --git a/src/hostmon.c b/src/hostmon.c
index d3c4028..0fcffda 100644
--- a/src/hostmon.c
+++ b/src/hostmon.c
@@ -17,7 +17,6 @@ Discovers LAN hosts and displays packet statistics for them
#include "deskman.h"
#include "fltdefs.h"
#include "fltselect.h"
-#include "isdntab.h" /* needed by packet.h */
#include "packet.h"
#include "ifaces.h"
#include "hostmon.h"
diff --git a/src/ifaces.c b/src/ifaces.c
index d860a0f..d11a857 100644
--- a/src/ifaces.c
+++ b/src/ifaces.c
@@ -271,14 +271,6 @@ int dev_bind_ifname(const int fd, const char const *ifname)
return dev_bind_ifindex(fd, ifr.ifr_ifindex);
}
-void isdn_iface_check(int *fd, char *ifname)
-{
- if (*fd == -1) {
- if (strncmp(ifname, "isdn", 4) == 0)
- *fd = open("/dev/isdnctrl", O_RDWR);
- }
-}
-
char *gen_iface_msg(char *ifptr)
{
static char if_msg[20];
diff --git a/src/ifaces.h b/src/ifaces.h
index d51044c..d753cac 100644
--- a/src/ifaces.h
+++ b/src/ifaces.h
@@ -22,7 +22,6 @@ int dev_clear_promisc(char *ifname);
int dev_get_ifname(int ifindex, char *ifname);
int dev_bind_ifindex(const int fd, const int ifindex);
int dev_bind_ifname(const int fd, const char const *ifname);
-void isdn_iface_check(int *fd, char *ifname);
char *gen_iface_msg(char *ifptr);
#endif /* IPTRAF_NG_IFACES_H */
diff --git a/src/ifstats.c b/src/ifstats.c
index 02c4f3a..01148ef 100644
--- a/src/ifstats.c
+++ b/src/ifstats.c
@@ -15,7 +15,6 @@ ifstats.c - the interface statistics module
#include "tui/winops.h"
#include "ifaces.h"
-#include "isdntab.h"
#include "fltdefs.h"
#include "fltselect.h"
#include "packet.h"
@@ -518,7 +517,6 @@ void ifstats(const struct OPTIONS *options, struct filterstate *ofilter,
goto err;
}
- //isdnfd = -1;
exitloop = 0;
gettimeofday(&tv, NULL);
start_tv = tv;
diff --git a/src/iptraf-ng-compat.h b/src/iptraf-ng-compat.h
index d252247..d21b689 100644
--- a/src/iptraf-ng-compat.h
+++ b/src/iptraf-ng-compat.h
@@ -40,7 +40,6 @@
#include <linux/if_packet.h>
#include <linux/if_fddi.h>
#include <linux/types.h>
-#include <linux/isdn.h>
#include <linux/if.h>
#include <linux/if_arp.h>
diff --git a/src/isdntab.c b/src/isdntab.c
deleted file mode 100644
index a226256..0000000
--- a/src/isdntab.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* For terms of usage/redistribution/modification see the LICENSE file */
-/* For authors and contributors see the AUTHORS file */
-
-/***
-
-isdntab.c - a set of simple routines that collect detected ISDN
- interfaces and record their link encapsulation.
-
-***/
-
-#include "iptraf-ng-compat.h"
-
-#include "isdntab.h"
-
-void add_isdn_entry(struct isdntab *list, char *ifname, int isdn_fd)
-{
- struct isdntabent *new_entry;
- isdn_net_ioctl_cfg isdn_cfg;
-
- new_entry = xmalloc(sizeof(struct isdntabent));
-
- strcpy(new_entry->ifname, ifname);
- new_entry->next_entry = NULL;
-
- if (list->head == NULL)
- list->head = new_entry;
-
- if (list->tail != NULL)
- list->tail->next_entry = new_entry;
-
- list->tail = new_entry;
-
- strcpy(isdn_cfg.name, ifname);
- ioctl(isdn_fd, IIOCNETGCF, &isdn_cfg);
- new_entry->encap = isdn_cfg.p_encap;
-}
-
-struct isdntabent *isdn_table_lookup(struct isdntab *list, char *ifname,
- int isdn_fd)
-{
- struct isdntabent *ptmp = list->head;
-
- while (ptmp != NULL) {
- if (strcmp(ptmp->ifname, ifname) == 0)
- break;
-
- ptmp = ptmp->next_entry;
- }
-
- if (ptmp == NULL) {
- add_isdn_entry(list, ifname, isdn_fd);
- ptmp = list->tail;
- }
- return ptmp;
-}
-
-void destroy_isdn_table(struct isdntab *list)
-{
- struct isdntabent *ptmp = list->head;
- struct isdntabent *ctemp = NULL;
-
- if (ptmp != NULL)
- ctemp = ptmp->next_entry;
-
- while (ptmp != NULL) {
- free(ptmp);
-
- ptmp = ctemp;
-
- if (ctemp != NULL)
- ctemp = ctemp->next_entry;
- }
-}
diff --git a/src/isdntab.h b/src/isdntab.h
deleted file mode 100644
index 48cb8ad..0000000
--- a/src/isdntab.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef IPTRAF_NG_ISDNTAB_H
-#define IPTRAF_NG_ISDNTAB_H
-
-struct isdntabent {
- char ifname[IFNAMSIZ];
- unsigned int encap;
- struct isdntabent *next_entry;
-};
-
-struct isdntab {
- struct isdntabent *head;
- struct isdntabent *tail;
-};
-
-void add_isdn_entry(struct isdntab *list, char *ifname, int isdn_fd);
-struct isdntabent *isdn_table_lookup(struct isdntab *list, char *ifname,
- int isdn_fd);
-void destroy_isdn_table(struct isdntab *list);
-
-#endif /* IPTRAF_NG_ISDNTAB_H */
diff --git a/src/itrafmon.c b/src/itrafmon.c
index fe52dc2..d00d917 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -17,7 +17,6 @@ itrafmon.c - the IP traffic monitor module
#include "othptab.h"
#include "fltdefs.h"
#include "fltselect.h"
-#include "isdntab.h"
#include "packet.h"
#include "ifaces.h"
#include "promisc.h"
@@ -734,7 +733,6 @@ void ipmon(struct OPTIONS *options, struct filterstate *ofilter,
goto err_close;
}
- //isdnfd = -1;
exitloop = 0;
gettimeofday(&tv, NULL);
starttime = timeint = closedint = tv.tv_sec;
diff --git a/src/packet.c b/src/packet.c
index c1baf3b..74d045b 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -16,20 +16,10 @@ packet.c - routines to open the raw socket, read socket data and
#include "fltdefs.h"
#include "fltselect.h"
#include "ipfilter.h"
-#include "isdntab.h"
#include "ifaces.h"
#include "packet.h"
#include "ipfrag.h"
-/* Reimplement again
- * Removed PPP, LINK_ISDN
- */
-
-/*
-int isdnfd;
-struct isdntab isdntable;
-*/
-
/* code taken from http://www.faqs.org/rfcs/rfc1071.html. See section 4.1 "C" */
static int in_cksum(u_short * addr, int len)
{
@@ -303,8 +293,5 @@ again: if (pkt->pkt_protocol == ETH_P_IP) {
void pkt_cleanup(void)
{
- // close(isdnfd);
- // isdnfd = -1;
destroyfraglist();
- // destroy_isdn_table(&isdntable);
}
diff --git a/src/packet.h b/src/packet.h
index f194db8..0bed4a0 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -22,8 +22,6 @@ packet.h - external declarations for packet.c
#define PACKET_FILTERED 3
#define MORE_FRAGMENTS 4
-extern int isdnfd;
-
struct pkt_hdr {
size_t pkt_bufsize;
char *pkt_payload;
diff --git a/src/pktsize.c b/src/pktsize.c
index 03d92df..a8c5d42 100644
--- a/src/pktsize.c
+++ b/src/pktsize.c
@@ -15,7 +15,6 @@ pktsize.c - the packet size breakdown facility
#include "dirs.h"
#include "fltdefs.h"
#include "fltselect.h"
-#include "isdntab.h"
#include "ifaces.h"
#include "packet.h"
#include "deskman.h"
diff --git a/src/serv.c b/src/serv.c
index b64acec..6777460 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -16,7 +16,6 @@ serv.c - TCP/UDP port statistics module
#include "dirs.h"
#include "deskman.h"
-#include "isdntab.h"
#include "fltdefs.h"
#include "fltselect.h"
#include "packet.h"
@@ -903,7 +902,6 @@ void servmon(char *ifname, const struct OPTIONS *options,
"******** TCP/UDP service monitor started ********");
}
- //isdnfd = -1;
exitloop = 0;
gettimeofday(&tv, NULL);
starttime = startlog = timeint = tv.tv_sec;
--
1.7.8.4
11 years
[PATCH] packet.h: decrease packet capture length to 96 bytes
by Vitezslav Samel
This size fits the comment above the definition and also
tcpdump has this default capture length.
Also reorganize the pkt_hdr strcture to have (almost) all
variables fitted into one CPU cacheline (should speed things up).
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/packet.h | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/packet.h b/src/packet.h
index dd24533..f194db8 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -7,15 +7,14 @@ packet.h - external declarations for packet.c
***/
+#include "fltselect.h"
+
/*
- * Number of bytes from captured packet to move into an aligned buffer.
+ * Number of bytes from captured packet to move into a buffer.
* 96 bytes should be enough for the IP header, TCP/UDP/ICMP/whatever header
* with reasonable numbers of options.
*/
-
-#include "fltselect.h"
-
-#define MAX_PACKET_SIZE 256 /* 256B should be enough to see all headers */
+#define MAX_PACKET_SIZE 96
#define INVALID_PACKET 0
#define PACKET_OK 1
@@ -26,17 +25,17 @@ packet.h - external declarations for packet.c
extern int isdnfd;
struct pkt_hdr {
- char pkt_buf[MAX_PACKET_SIZE];
size_t pkt_bufsize;
char *pkt_payload;
size_t pkt_caplen; /* bytes captured */
size_t pkt_len; /* bytes on-the-wire */
- unsigned short pkt_protocol; /* Physical layer protocol: ETH_P_* */
int pkt_ifindex; /* Interface number */
+ unsigned short pkt_protocol; /* Physical layer protocol: ETH_P_* */
unsigned short pkt_hatype; /* Header type: ARPHRD_* */
unsigned char pkt_pkttype; /* Packet type: PACKET_OUTGOING, PACKET_BROADCAST, ... */
unsigned char pkt_halen; /* Length of address */
unsigned char pkt_addr[8]; /* Physical layer address */
+ char pkt_buf[MAX_PACKET_SIZE];
};
#define PACKET_INIT(packet) \
--
1.7.8.4
11 years
[PATCH 0/8] cleanups and a fix
by Vitezslav Samel
Vitezslav Samel (8):
iptraf.c: remove unused code
fltmgr.h: remove unneded IGNORE_FILTER_PROTOTYPES #ifdef
rename local variable exitloop in tui/*.c to endloop
sanitize extern variables
removeaport(): fix segfault when there are no ports to remove
remove circular dependency between serv.h and options.h
remove unused #ifndef conditionals
use integer constant when dealing with integer variables
src/deskman.h | 1 +
src/detstats.c | 3 ---
src/error.c | 2 --
src/fltmgr.h | 2 --
src/hostmon.c | 3 ---
src/hostmon.h | 1 +
src/ifstats.c | 3 ---
src/instances.h | 4 ----
src/iptraf-ng-compat.h | 3 +++
src/iptraf.c | 27 +++------------------------
src/itrafmon.c | 6 +-----
src/options.c | 12 +++++++++---
src/options.h | 4 +---
src/othptab.c | 3 +--
src/packet.c | 2 --
src/pktsize.c | 3 ---
src/rvnamed.c | 4 ----
src/serv.c | 14 ++++++++------
src/serv.h | 2 +-
src/tcptable.c | 3 +--
src/tui/input.c | 10 ++++------
src/tui/listbox.c | 8 ++++----
src/tui/menurt.c | 10 +++++-----
src/tui/menurt.h | 16 ++++++++--------
24 files changed, 51 insertions(+), 95 deletions(-)
--
1.7.8.4
11 years
iptraf-ng 1.1.3
by Nikola Pajkovsky
Ok, another version of iptraf-ng is out and ready. As usual we did a
code clean up, add support for SIT tunnels, and more important is, that
we fix two nasty bugs. One is regression, where we count packets even
though there weren't one and the second is segfault, where in some cases
window size was off-by-one.
We drop support for autotools and use only Makefiles. Makefile has
automatic detection of ncurses. It firstly start looking for
ncurses5-config and if fails it continues in sequence ncursesw5-config,
ncurses6-config and ncursesw6-config
If you want to override any ncurses-config, use of the commands:
$ make NEEDS_NCURSESW5=YesPlease
$ make NEEDS_NCURSES6=YesPlease
$ make NEEDS_NCURSESW6=YesPlease
other options is that you can create file config.mak and defie one of
the NEEDS_NCURSES* variable.
Nikola Pajkovsky (7):
build: introduce new building system
wrapper: get rid of unused vasprintf GNU extension
build: force to regenerate VERSION-FILE
winops: fix the off-by-one error
build: fix ncurses cflags and ldflags
build: add support for ncurses[w][5,6]
iptraf-ng 1.1.3
Vitezslav Samel (44):
move changes of original iptraf to CHANGES.old
CHANGES: add changelog for older releases
move struct ifcounts
move struct iflist and iftab
create counters.c
serv.c: remove unused functions
externs.h cleanup: detstats()
externs.h cleanup: *options()
externs.h cleanup: kill unused ip_host_breakdown() declaration
externs.h cleanup: ifstats(), selectiface()
externs.h cleanup: ipmon()
externs.h cleanup: packet_size_breakdown()
externs.h cleanup: servmon()
externs.h cleanup: hostmon()
externs.h: remove this file
CHANGES: set date of 1.1.2 release
packet.c: packet_get() fix
packet.c: packet_adjust(): support SIT tunnels
struct othptabent: make more room for MAC addrs
initiflist(): sort interfaces by ifindex
use xmallocz()
Makefile: dependency fix
set the right default version
Makefile: link rvnamed with $(ALL_LDFLAGS)
add moving average computing functions
add timeval_diff_msec() function
use struct rate in ifstats()
use struct rate in detstats()
use IPTRAF_NAME where appropriate
kill NULL pointer casting
sanitize check_rotate_flag() calls
fix dependency for files with IPTRAF_NAME and/or IPTRAF_VERSION
merge tui/tui.h into tui/msgboxes.h
use iptraf-ng-compat.h for system headers in src/tui/*
merge src/tui/txbox.c into src/tui/winops.c
remove inclusion of non-system headers from iptraf-ng-compat.h
use xmalloc[z]() instead of plain malloc()
add info about authorship into tui/*.c
packet.c: in_cksum(): fix checksumming for odd-sized IPv4 header
packet_get(): don't try to receive packet in case of error
packet_get(): propagate errors to the callers and check for them
packet_get(): use poll() instead of select()
make more room for MAC addrs (take 2)
CHANGES: prepare for release
--
Nikola
11 years
[PATCH 0/2] iptraf-ng: fix and preparation for release
by Vitezslav Samel
1st patch: last moment fix
2nd patch: preparation for today's release (if not today, change
the date in the CHANGES file)
Vitezslav Samel (2):
make more room for MAC addrs (take 2)
CHANGES: prepare for release
CHANGES | 11 +++++++++++
src/othptab.c | 4 ++--
src/tcptable.c | 8 ++++----
src/tcptable.h | 2 +-
4 files changed, 18 insertions(+), 7 deletions(-)
--
1.7.8.4
11 years
[PATCH 0/3] iptraf-ng: fixes
by Vitezslav Samel
The first two patches are fixes/enhancements.
The third one is only for review (works for me without problems, but I don't
see any improvement); it's on you, if you apply this.
Vitezslav Samel (3):
packet_get(): don't try to receive packet in case of error
packet_get(): propagate errors to the callers and check for them
packet_get(): use poll() instead of select()
src/detstats.c | 6 +++++-
src/hostmon.c | 6 +++++-
src/ifstats.c | 6 +++++-
src/iptraf-ng-compat.h | 1 +
src/itrafmon.c | 6 +++++-
src/packet.c | 43 ++++++++++++++++++++++---------------------
src/packet.h | 2 +-
src/pktsize.c | 6 +++++-
src/serv.c | 6 +++++-
9 files changed, 54 insertions(+), 28 deletions(-)
--
1.7.8.4
11 years
[PATCH] packet.c: in_cksum(): fix checksumming for odd-sized IPv4 header
by Vitezslav Samel
Commit "new ip checksum based on rfc1071 implementaion" introduced
a bug which incorrectly computes checksum in case of odd-sized
IPv4 header. This barely happens, so this remained unnoticed for
so long.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/packet.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/packet.c b/src/packet.c
index 841a495..6df69b7 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -42,7 +42,7 @@ static int in_cksum(u_short * addr, int len)
len -= 2;
}
- if (len > 1)
+ if (len > 0)
sum += *(unsigned char *) addr;
while (sum >> 16)
--
1.7.8.4
11 years
[PATCH 0/6] iptraf-ng: cleanups
by Vitezslav Samel
Vitezslav Samel (6):
merge tui/tui.h into tui/msgboxes.h
use iptraf-ng-compat.h for system headers in src/tui/*
merge src/tui/txbox.c into src/tui/winops.c
remove inclusion of non-system headers from iptraf-ng-compat.h
use xmalloc[z]() instead of plain malloc()
add info about authorship into tui/*.c
Makefile | 2 --
src/bar.c | 2 ++
src/deskman.c | 4 ++++
src/detstats.c | 3 ++-
src/error.c | 3 +--
src/fltedit.c | 6 +++++-
src/fltmgr.c | 8 +++++++-
src/fltselect.c | 5 ++++-
src/hostmon.c | 3 +++
src/ifstats.c | 6 +++++-
src/ipfilter.c | 5 ++++-
src/iptraf-ng-compat.h | 9 ---------
src/iptraf.c | 3 +++
src/itrafmon.c | 3 +++
src/landesc.c | 7 ++++++-
src/log.c | 5 ++++-
src/options.c | 6 +++++-
src/othptab.c | 2 ++
src/pktsize.c | 2 ++
src/serv.c | 6 +++++-
src/tcptable.c | 2 ++
src/tui/input.c | 11 +++++------
src/tui/input.h | 2 --
src/tui/labels.c | 5 +++--
src/tui/labels.h | 2 --
src/tui/listbox.c | 11 ++++-------
src/tui/listbox.h | 2 --
src/tui/menurt.c | 10 ++++------
src/tui/msgboxes.c | 5 +++--
src/tui/msgboxes.h | 2 ++
src/tui/tui.h | 9 ---------
src/tui/txbox.c | 39 ---------------------------------------
src/tui/winops.c | 38 ++++++++++++++++++++++++++++++++++----
src/tui/winops.h | 1 -
34 files changed, 124 insertions(+), 105 deletions(-)
delete mode 100644 src/tui/tui.h
delete mode 100644 src/tui/txbox.c
--
1.7.8.4
11 years
[PATCH v3] build: add support for ncurses[w][5,6]
by Nikola Pajkovsky
now iptraf-ng is able to build against any ncurses library.
By default, iptraf-ng tries to find installed ncurses-config binary file
and set flags.
On Debian system, it will fails if libncuses5-dev is not installed,
because ncurses5-config is installed with essential package ncurses-bin.
If you want to override any ncurses-config, use of the commands:
$ make NEEDS_NCURSESW5=YesPlease
$ make NEEDS_NCURSES6=YesPlease
$ make NEEDS_NCURSESW6=YesPlease
or define it in Makefile or in config.mak
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
Makefile | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 65 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index dd5aed2..7a483ee 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,16 @@ all::
# Define V=1 to have a more verbose compile.
#
-# Define NO_NCURSES if not linking with ncurses.
+# Define NO_PANEL if you don't want to use -lpanel.
+#
+# Define NEEDS_NCURSES5 if you need linking with ncurses5.
+#
+# Define NEEDS_NCURSESW5 if you need linking with ncursesw5.
+#
+# Define NEEDS_NCURSES6 if you need linking with ncurses6.
+#
+# Define NEEDS_NCURSESW6 if you need linking with ncursesw6.
+
VERSION-FILE: FORCE
@$(SHELL_PATH) ./GEN-VERSION-FILE
@@ -196,26 +205,67 @@ $(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
endif
endif
-ifndef NO_NCURSES
-NCURSES6_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
-ifneq ($(NCURSES6_CFLAGS),)
-NCURSES_CFLAGS += $(NCURSES6_CFLAGS)
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSES5
+ NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+endif
+endif
+
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSESW5
+ NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+endif
+endif
+
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSES6
+ NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
endif
-NCURSES6_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
-ifneq ($(NCURSES6_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES6_LDFLAGS)
endif
-NCURSES5_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
-ifneq ($(NCURSES5_CFLAGS),)
-NCURSES_CFLAGS += $(NCURSES5_CFLAGS)
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSESW6
+ NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
endif
-NCURSES5_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
-ifneq ($(NCURSES5_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES5_LDFLAGS)
endif
-NCURSES_LDFLAGS += -lpanel
+# try find ncuses by autodetect
+ifndef NCURSES_LDFLAGS
+ ifneq ($(shell ncurses5-config --libs 2>/dev/null),)
+ NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
+ else ifneq ($(shell ncursesw5-config --libs 2>/dev/null),)
+ NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
+ else ifneq ($(shell ncurses6-config --libs 2>/dev/null),)
+ NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
+ else ifneq ($(shell ncursesw6-config --libs 2>/dev/null),)
+ NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
+ endif
+
+ ifneq ($(NCURSES_LDFLAGS),)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+ endif
endif
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
--
1.7.10
11 years
[PATCH v2] build: add support for ncurses[w][5,6]
by Nikola Pajkovsky
now iptraf-ng is able to build against any ncurses library.
By default, iptraf-ng is built with ncurses5 lib. If you want to override
it, use of the commands:
$ make NEEDS_NCURSESW5=YesPlease
$ make NEEDS_NCURSES6=YesPlease
$ make NEEDS_NCURSESW6=YesPlease
or define it in Makefile
---
I'm really not happy with that autodetection.
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
Makefile | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 75 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index dd5aed2..b014f89 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,16 @@ all::
# Define V=1 to have a more verbose compile.
#
-# Define NO_NCURSES if not linking with ncurses.
+# Define NO_PANEL if you don't want to use -lpanel.
+#
+# Define NEEDS_NCURSES5 if you need linking with ncurses5.
+#
+# Define NEEDS_NCURSESW5 if you need linking with ncursesw5.
+#
+# Define NEEDS_NCURSES6 if you need linking with ncurses6.
+#
+# Define NEEDS_NCURSESW6 if you need linking with ncursesw6.
+
VERSION-FILE: FORCE
@$(SHELL_PATH) ./GEN-VERSION-FILE
@@ -196,26 +205,77 @@ $(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
endif
endif
-ifndef NO_NCURSES
-NCURSES6_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
-ifneq ($(NCURSES6_CFLAGS),)
-NCURSES_CFLAGS += $(NCURSES6_CFLAGS)
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSES5
+ NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+endif
+endif
+
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSESW5
+ NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+endif
+endif
+
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSES6
+ NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
endif
-NCURSES6_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
-ifneq ($(NCURSES6_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES6_LDFLAGS)
endif
-NCURSES5_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
-ifneq ($(NCURSES5_CFLAGS),)
-NCURSES_CFLAGS += $(NCURSES5_CFLAGS)
+ifndef NCURSES_LDFLAGS
+ifdef NEEDS_NCURSESW6
+ NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
endif
-NCURSES5_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
-ifneq ($(NCURSES5_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES5_LDFLAGS)
endif
-NCURSES_LDFLAGS += -lpanel
+# try find ncuses by autodetect
+ifndef NCURSES_LDFLAGS
+ TRY_NCURSES := $(shell ncurses5-config --libs 2>/dev/null)
+ ifneq ($(TRY_NCURSES),)
+ NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
+ else
+ TRY_NCURSES := $(shell ncursesw5-config --libs 2>/dev/null)
+ ifneq ($(TRY_NCURSES),)
+ NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
+ else
+ TRY_NCURSES := $(shell ncurses6-config --libs 2>/dev/null)
+ ifneq ($(TRY_NCURSES),)
+ NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
+ else
+ TRY_NCURSES := $(shell ncursesw6-config --libs 2>/dev/null)
+ ifneq ($(TRY_NCURSES),)
+ NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
+ NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
+ endif
+ endif
+ endif
+ endif
+
+ ifneq ($(TRY_NCURSES),)
+ ifndef NO_PANEL
+ NCURSES_LDFLAGS += -lpanel
+ endif
+ endif
endif
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
--
1.7.10
11 years