Browse code

Add dstat, iptraf, nicstat, lldpad(need libconfig) to extra packages.

Change-Id: I2b6fa18382a7b517c95b8d7233a67395ad89030a
Reviewed-on: http://photon-jenkins.eng.vmware.com/194
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George

xiaolin-vmware authored on 2015/12/02 05:37:39
Showing 22 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,34 @@
0
+Summary: Versatile resource statistics tool
1
+Name:    dstat
2
+Version: 0.7.2
3
+Release: 1%{?dist}
4
+License: GPLv2
5
+URL: http://dag.wiee.rs/home-made/dstat/
6
+Source: %{name}-%{version}.tar.bz2
7
+%define sha1 dstat=10baf061e3d38e1234fb99182fc53509adf07269
8
+Group:      Development/Tools
9
+Vendor:     VMware, Inc.
10
+Distribution:  Photon
11
+
12
+%description
13
+Dstat gives you detailed selective information in columns and clearly indicates in what magnitude and unit the output is displayed. Less confusion, less mistakes. And most importantly, it makes it very easy to write plugins to collect your own counters and extend in ways you never expected. 
14
+
15
+%prep
16
+%setup -q
17
+
18
+%install
19
+%{__rm} -rf %{buildroot}
20
+%{__make} install DESTDIR="%{buildroot}"
21
+
22
+%clean
23
+%{__rm} -rf %{buildroot}
24
+
25
+%files
26
+%defattr(-, root, root, 0755)
27
+%doc %{_mandir}/*
28
+%{_bindir}/dstat
29
+%{_datadir}/dstat/
30
+
31
+%changelog
32
+*	Mon Nov 30 2015 Xiaolin Li <xiaolinl@vmware.com> 0.7.2-1
33
+-   Initial build.  First version
0 34
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+From 74581ec4f4ebd7abf68c5ab042164dc0b77133ba Mon Sep 17 00:00:00 2001
1
+From: Nikola Pajkovsky <npajkovs@redhat.com>
2
+Date: Wed, 17 Mar 2010 17:24:48 +0100
3
+Subject: [PATCH] fix strcpy overlap memory
4
+
5
+Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
6
+---
7
+ src/ifaces.c |    2 +-
8
+ 1 files changed, 1 insertions(+), 1 deletions(-)
9
+
10
+diff --git a/src/ifaces.c b/src/ifaces.c
11
+index 8447f51..ecb8a2d 100644
12
+--- a/src/ifaces.c
13
+@@ -51,7 +51,7 @@ char *ltrim(char *buf)
14
+     while ((*tmp == ' ') || (*tmp == '\t'))
15
+         tmp++;
16
+ 
17
+-    strcpy(buf, tmp);
18
++    memmove(buf, tmp, strlen(buf));
19
+     return buf;
20
+ }
21
+ 
22
+-- 
23
+1.6.6.1
24
+
0 25
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+--- iptraf-3.0.0/src/Makefile.orig	2005-09-13 11:11:17.000000000 +0200
1
+@@ -32,7 +32,7 @@
2
+ # modified (except for -m486 on non-Intel x86 platforms).
3
+ 
4
+ CFLAGS		= -Wall #-O2 #-m486
5
+-DIRS		= -DWORKDIR=\"$(WORKDIR)\" \
6
++DIRS		= -DWORKDIR=\"$(WORKDIR)\" -DLOCKDIR=\"$(LOCKDIR)\" \
7
+ 		  -DLOGDIR=\"$(LOGDIR)\" -DEXECDIR=\"$(TARGET)\"
8
+ LDOPTS		= #-static
9
+ 
0 10
new file mode 100644
... ...
@@ -0,0 +1,38 @@
0
+Patch by Robert Scheck <redhat@linuxnetz.de> for iptraf >= 2.7.0 to set the 
1
+correct paths to some iptraf specific files in the man pages.
2
+
3
+This patch solves bug #128476
4
+
5
+--- iptraf-2.7.0/Documentation/iptraf.8		2002-03-18 09:05:19.000000000 +0100
6
+@@ -86,7 +86,7 @@
7
+ 
8
+ .SH FILES
9
+  /var/log/iptraf/*.log - log file
10
+- /var/local/iptraf/* - important IPTraf data files
11
++ /var/lib/iptraf/* - important IPTraf data files
12
+ 
13
+ .SH SEE ALSO
14
+  Documentation/* - complete documentation written by the author
15
+--- iptraf-2.7.0/Documentation/rvnamed.8	2000-03-13 13:03:59.000000000 +0100
16
+@@ -11,7 +11,7 @@
17
+ This program is only used by iptraf and, therefore, is useless alone.
18
+ 
19
+ .SH FILES
20
+- /var/local/iptraf/rvnamed.log - log file
21
++ /var/log/iptraf/rvnamed.log - log file
22
+ 
23
+ .SH SEE ALSO
24
+ README.rvnamed - documentation from the author
25
+--- iptraf-3.0.0/Documentation/config.html.orig	2005-08-04 09:16:14.000000000 +0200
26
+@@ -82,7 +82,7 @@
27
+   main menu. The configuration is stored in the
28
+   <TT
29
+ CLASS="FILENAME"
30
+->/var/local/iptraf/iptraf.cfg</TT
31
++>/var/lib/iptraf.cfg</TT
32
+ > file. If the file is not found, IPTraf uses
33
+   the default settings. Any changes to the configuration immediately get
34
+   stored in the configuration file.</P
0 35
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+diff -u iptraf-3.0.0/src/install.sh iptraf-3.0.0/src/install.sh
1
+--- iptraf-3.0.0/src/install.sh	2006-01-30 15:37:34.000000000 +0100
2
+@@ -23,9 +23,9 @@
3
+ echo "*** Installing executable programs and preparing work directories"
4
+ echo
5
+ echo ">>> Installing iptraf in $TARGET"
6
+-$INSTALL -m 0700 -o root -g root -s iptraf $TARGET
7
++$INSTALL -m 0700 -s iptraf $TARGET
8
+ echo ">>> Installing rvnamed in $TARGET"
9
+-$INSTALL -m 0700 -o root -g root -s rvnamed $TARGET
10
++$INSTALL -m 0700 -s rvnamed $TARGET
11
+ 
12
+ if [ ! -d $WORKDIR ]; then
13
+     echo ">>> Creating IPTraf work directory $WORKDIR"
14
+@@ -34,21 +34,21 @@
15
+     rm -f $WORKDIR/othfilter.dat
16
+ fi
17
+ 
18
+-$INSTALL -m 0700 -o root -g root -d $WORKDIR
19
++$INSTALL -m 0700 -d $WORKDIR
20
+ 
21
+ if [ ! -d $LOGDIR ]; then
22
+     echo ">>> Creating IPTraf log directory $LOGDIR"
23
+ else
24
+     echo ">>> IPTraf log directory $LOGDIR already exists"
25
+ fi
26
+-$INSTALL -m 0700 -o root -g root -d $LOGDIR
27
++$INSTALL -m 0700 -d $LOGDIR
28
+ 
29
+ if [ ! -d $LOCKDIR ]; then
30
+     echo ">>> Creating IPTraf lockfile directory $LOCKDIR"
31
+ else
32
+     echo ">>> IPTraf lockfile directory $LOCKDIR already exists"
33
+ fi
34
+-$INSTALL -m 0700 -o root -g root -d $LOCKDIR
35
++$INSTALL -m 0700 -d $LOCKDIR
36
+ echo
37
+ echo
38
+ echo "*** iptraf, and rvnamed executables are in $TARGET"
39
+@@ -74,7 +74,6 @@
40
+ fi
41
+ ####################################################################
42
+ 
43
+-cat version > $WORKDIR/version
44
+ 
45
+ echo 
46
+ echo
47
+@@ -85,13 +84,13 @@
48
+ echo "this version. You can view this file now (will require the 'less'"
49
+ echo "program in /usr/bin.  Press Q to quit when done)."
50
+ echo
51
+-echo -n "Would you like to view the RELEASE-NOTES file now (Y/N)? "; read YESNO
52
+-
53
+-if [ "$YESNO" = "y" -o "$YESNO" = "Y" ]; then
54
+-    less ../RELEASE-NOTES
55
+-fi
56
+-
57
+-clear
58
++#echo -n "Would you like to view the RELEASE-NOTES file now (Y/N)? "; read YESNO
59
++#
60
++#if [ "$YESNO" = "y" -o "$YESNO" = "Y" ]; then
61
++#    less ../RELEASE-NOTES
62
++#fi
63
++#
64
++#clear
65
+ echo
66
+ echo "====================================================================="
67
+ echo
0 68
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+--- iptraf-3.0.0/src/install.sh.orig	2006-01-30 15:37:34.000000000 +0100
1
+@@ -23,9 +23,9 @@
2
+ echo "*** Installing executable programs and preparing work directories"
3
+ echo
4
+ echo ">>> Installing iptraf in $TARGET"
5
+-$INSTALL -m 0700 -s iptraf $TARGET
6
++$INSTALL -m 0700 iptraf $TARGET
7
+ echo ">>> Installing rvnamed in $TARGET"
8
+-$INSTALL -m 0700 -s rvnamed $TARGET
9
++$INSTALL -m 0700 rvnamed $TARGET
10
+ 
11
+ if [ ! -d $WORKDIR ]; then
12
+     echo ">>> Creating IPTraf work directory $WORKDIR"
0 13
new file mode 100644
... ...
@@ -0,0 +1,180 @@
0
+--- ./src/hostmon.c.old	2007-01-31 12:20:24.000000000 -0800
1
+@@ -711,7 +711,7 @@
2
+     int is_ip;
3
+     int ch;
4
+ 
5
+-    char ifname[10];
6
++    char ifname[18];
7
+ 
8
+     struct timeval tv;
9
+     unsigned long starttime;
10
+--- ./src/hostmon.h.old	2007-01-31 12:20:24.000000000 -0800
11
+@@ -25,7 +25,7 @@
12
+             char eth_addr[ETH_ALEN];
13
+             char ascaddr[15];
14
+             char desc[65];
15
+-            char ifname[10];
16
++            char ifname[18];
17
+             int withdesc;
18
+             int printed;
19
+             unsigned int linktype;
20
+--- ./src/ifstats.c.old	2007-01-31 12:20:24.000000000 -0800
21
+@@ -128,7 +128,7 @@
22
+ void initiflist(struct iflist **list)
23
+ {
24
+     FILE *fd;
25
+-    char ifname[10];
26
++    char ifname[18];
27
+     struct iflist *itmp = NULL;
28
+     struct iflist *tail = NULL;
29
+     unsigned int index = 0;
30
+@@ -430,7 +430,7 @@
31
+     FILE *logfile = NULL;
32
+ 
33
+     int br;
34
+-    char ifname[10];
35
++    char ifname[18];
36
+ 
37
+     int ch;
38
+ 
39
+@@ -757,7 +757,7 @@
40
+     char *tpacket;
41
+     unsigned int iphlen;
42
+ 
43
+-    char ifname[10];
44
++    char ifname[18];
45
+     struct sockaddr_ll fromaddr;
46
+     unsigned short linktype;
47
+ 
48
+--- ./src/ifstats.h.old	2007-01-31 12:20:24.000000000 -0800
49
+@@ -6,7 +6,7 @@
50
+ ***/
51
+ 
52
+ struct iflist {
53
+-    char ifname[8];
54
++    char ifname[18];
55
+     unsigned int encap;
56
+     unsigned long long iptotal;
57
+     unsigned long long ip6total;
58
+--- ./src/iptraf.c.old	2007-01-31 12:20:24.000000000 -0800
59
+@@ -235,7 +235,7 @@
60
+     struct filterstate ofilter;
61
+     struct ffnode *fltfiles;
62
+ 
63
+-    char ifname[10];
64
++    char ifname[18];
65
+     char *ifptr = NULL;
66
+     struct porttab *ports;
67
+ 
68
+--- ./src/isdntab.h.old	2007-01-31 12:20:24.000000000 -0800
69
+@@ -1,5 +1,5 @@
70
+ struct isdntabent {
71
+-    char ifname[10];
72
++    char ifname[18];
73
+     unsigned int encap;
74
+     struct isdntabent *next_entry;
75
+ };
76
+--- ./src/itrafmon.c.old	2007-01-31 12:20:24.000000000 -0800
77
+@@ -604,7 +604,7 @@
78
+     int curwin = 0;
79
+ 
80
+     int readlen;
81
+-    char ifname[10];
82
++    char ifname[18];
83
+ 
84
+     unsigned long long total_pkts = 0;
85
+ 
86
+--- ./src/promisc.h.old	2007-01-31 12:20:24.000000000 -0800
87
+@@ -9,7 +9,7 @@
88
+  */
89
+ 
90
+ struct promisc_params {
91
+-    char ifname[8];
92
++    char ifname[18];
93
+     int saved_state;
94
+     int state_valid;
95
+ };
96
+--- ./src/tcptable.h.old	2007-01-31 12:20:24.000000000 -0800
97
+@@ -64,7 +64,7 @@
98
+     unsigned long finack;
99
+     int partial;
100
+     int finsent;
101
+-    char ifname[8];
102
++    char ifname[18];
103
+     unsigned int index;
104
+     int reused;
105
+     int timedout;
106
+--- ./src/ifstats.c.old	2007-01-31 12:53:22.000000000 -0800
107
+@@ -142,7 +142,7 @@
108
+         return;
109
+     }
110
+ 
111
+-    while (get_next_iface(fd, ifname, 8)) {
112
++    while (get_next_iface(fd, ifname, 12)) {
113
+         if (strcmp(ifname, "") != 0) {
114
+             if (!(iface_supported(ifname)))
115
+                 continue;
116
+--- ./src/promisc.c.old	2007-01-31 12:53:28.000000000 -0800
117
+@@ -49,7 +49,7 @@
118
+ {
119
+     FILE *fd;
120
+     int ifd;
121
+-    char buf[8];
122
++    char buf[18];
123
+     struct promisc_states *ptmp;
124
+     struct promisc_states *tail = NULL;
125
+     struct ifreq ifr;
126
+@@ -61,7 +61,7 @@
127
+     *list = NULL;
128
+     fd = open_procnetdev();
129
+ 
130
+-    while (get_next_iface(fd, buf, 8)) {
131
++    while (get_next_iface(fd, buf, 12)) {
132
+         if (strcmp(buf, "") != 0) {
133
+             ptmp = malloc(sizeof(struct promisc_states));
134
+             strcpy(ptmp->params.ifname, buf);
135
+--- ./src/othptab.h.old	2007-01-31 13:04:48.000000000 -0800
136
+@@ -42,7 +42,7 @@
137
+     int s_fstat;
138
+     int d_fstat;
139
+     unsigned int protocol;
140
+-    char iface[8];
141
++    char iface[18];
142
+     unsigned int pkt_length;
143
+ 
144
+     union {
145
+--- ./src/pktsize.c.old	2007-01-31 13:05:03.000000000 -0800
146
+@@ -175,7 +175,7 @@
147
+     char buf[MAX_PACKET_SIZE];
148
+     int br;
149
+     char *ipacket;
150
+-    char iface[10];
151
++    char iface[18];
152
+     unsigned int mtu;
153
+ 
154
+     struct sockaddr_ll fromaddr;
155
+--- ./src/serv.c.old	2007-01-31 13:05:07.000000000 -0800
156
+@@ -739,7 +739,7 @@
157
+     unsigned short linktype;
158
+     int br;
159
+ 
160
+-    char iface[8];
161
++    char iface[18];
162
+     unsigned int idx = 1;
163
+ 
164
+     unsigned int sport = 0;
165
+
0 166
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+--- iptraf-3.0.0/src/serv.c.in	2006-12-11 11:13:27.000000000 +0100
1
+@@ -333,7 +333,7 @@
2
+         }
3
+ 
4
+         dport_listent->ibcount += br;
5
+-        dport_listent->spans.spanbr_out += br;
6
++        dport_listent->spans.spanbr_in += br;
7
+         dport_listent->icount++;
8
+     }
9
+     if (sport_listent != NULL || dport_listent != NULL) {
0 10
new file mode 100644
... ...
@@ -0,0 +1,68 @@
0
+--- iptraf-3.0.0/src/packet.c.interface	2005-09-13 08:42:54.000000000 +0200
1
+@@ -102,11 +102,19 @@ unsigned short getlinktype(unsigned shor
2
+         else if (strncmp(ifname, "tun", 3) == 0)
3
+             result = LINK_ETHERNET;
4
+         else if (strncmp(ifname, "vlan", 3) == 0)
5
+-            result = LINK_VLAN;
6
++            result = LINK_ETHERNET;
7
++        else if (strncmp(ifname, "bond", 4) == 0)
8
++            result = LINK_ETHERNET;
9
+         else if (strncmp(ifname, "brg", 3) == 0)
10
+             result = LINK_ETHERNET;
11
+         else if (strncmp(ifname, "tap", 3) == 0)
12
+             result = LINK_ETHERNET;
13
++        else if (strncmp(ifname, "ctc", 3) == 0)
14
++            result = LINK_ETHERNET;
15
++        else if (strncmp(ifname, "hsi", 3) == 0)
16
++            result = LINK_ETHERNET;
17
++        else if (strncmp(ifname, "ath", 3) == 0)
18
++            result = LINK_ETHERNET;
19
+         else if ((strncmp(ifname, "isdn", 4) == 0) && (isdn_fd != -1)) {
20
+             isdnent = isdn_table_lookup(isdnlist, ifname, isdn_fd);
21
+ 
22
+@@ -235,6 +243,7 @@ void adjustpacket(char *tpacket, unsigne
23
+          */
24
+         memmove(aligned_buf, *packet, min(SNAPSHOT_LEN, *readlen));
25
+         *packet = aligned_buf;
26
++	break;
27
+     default:
28
+         *packet = (char *) NULL;        /* return a NULL packet to signal */
29
+         break;                  /* an unrecognized link protocol */
30
+@@ -344,9 +353,14 @@ int processpacket(char *tpacket, char **
31
+      * Get IPTraf link type based on returned information and move past
32
+      * data link header.
33
+      */
34
+-    *linktype =
35
+-        getlinktype(fromaddr->sll_hatype, ifname, isdnfd, &isdntable);
36
+     fromaddr->sll_protocol = ntohs(fromaddr->sll_protocol);
37
++    if (fromaddr->sll_protocol != ETH_P_8021Q)
38
++        *linktype =
39
++            getlinktype(fromaddr->sll_hatype, ifname, isdnfd, &isdntable);
40
++    else {
41
++        *linktype = LINK_VLAN;
42
++        fromaddr->sll_protocol = ntohs(*((unsigned short*)(tpacket+ETH_HLEN+2)));
43
++    }
44
+     adjustpacket(tpacket, *linktype, packet, aligned_buf, br);
45
+ 
46
+     if (*packet == NULL)
47
+--- iptraf-3.0.0/src/ifaces.c.interface	2005-09-13 08:42:54.000000000 +0200
48
+@@ -32,14 +32,15 @@ details.
49
+ #include "error.h"
50
+ 
51
+ extern int accept_unsupported_interfaces;
52
+-#define NUM_SUPPORTED_IFACES 26
53
++#define NUM_SUPPORTED_IFACES 30
54
+ 
55
+ extern int daemonized;
56
+ 
57
+ char ifaces[][6] =
58
+     { "lo", "eth", "sl", "ppp", "ippp", "plip", "fddi", "isdn", "dvb",
59
+     "pvc", "hdlc", "ipsec", "sbni", "tr", "wvlan", "wlan", "sm2", "sm3",
60
+-    "pent", "lec", "brg", "tun", "tap", "cipcb", "tunl", "vlan"
61
++    "pent", "lec", "brg", "tun", "tap", "cipcb", "tunl", "vlan", "hsi",
62
++    "ctc", "ath", "bond"
63
+ };
64
+ 
65
+ char *ltrim(char *buf)
0 66
new file mode 100644
... ...
@@ -0,0 +1,96 @@
0
+--- iptraf-3.0.0/src/promisc.c.longdev	2005-09-13 08:42:54.000000000 +0200
1
+@@ -61,9 +61,7 @@
2
+     *list = NULL;
3
+     fd = open_procnetdev();
4
+ 
5
+-    do {
6
+-        get_next_iface(fd, buf);
7
+-
8
++    while (get_next_iface(fd, buf, 8)) {
9
+         if (strcmp(buf, "") != 0) {
10
+             ptmp = malloc(sizeof(struct promisc_states));
11
+             strcpy(ptmp->params.ifname, buf);
12
+@@ -102,7 +100,7 @@
13
+                 }
14
+             }
15
+         }
16
+-    } while (strcmp(buf, "") != 0);
17
++    }
18
+ }
19
+ 
20
+ /*
21
+--- iptraf-3.0.0/src/ifaces.h.longdev	2005-09-13 08:42:54.000000000 +0200
22
+@@ -6,7 +6,7 @@
23
+ ***/
24
+ 
25
+ FILE *open_procnetdev(void);
26
+-void get_next_iface(FILE * fd, char *ifname);
27
++int get_next_iface(FILE * fd, char *ifname, int n);
28
+ int iface_supported(char *iface);
29
+ int iface_up(char *iface);
30
+ void err_iface_unsupported(void);
31
+--- iptraf-3.0.0/src/ifstats.c.longdev	2005-09-13 08:42:54.000000000 +0200
32
+@@ -128,7 +128,6 @@
33
+ void initiflist(struct iflist **list)
34
+ {
35
+     FILE *fd;
36
+-    char buf[161];
37
+     char ifname[10];
38
+     struct iflist *itmp = NULL;
39
+     struct iflist *tail = NULL;
40
+@@ -143,9 +142,7 @@
41
+         return;
42
+     }
43
+ 
44
+-    do {
45
+-        strcpy(buf, "");
46
+-        get_next_iface(fd, ifname);
47
++    while (get_next_iface(fd, ifname, 8)) {
48
+         if (strcmp(ifname, "") != 0) {
49
+             if (!(iface_supported(ifname)))
50
+                 continue;
51
+@@ -183,7 +180,7 @@
52
+             tail = itmp;
53
+             itmp->next_entry = NULL;
54
+         }
55
+-    } while (strcmp(ifname, "") != 0);
56
++    }
57
+ 
58
+     fclose(fd);
59
+ }
60
+--- iptraf-3.0.0/src/ifaces.c.longdev	2006-03-31 13:42:39.000000000 +0200
61
+@@ -81,19 +81,23 @@
62
+ /*
63
+  * Get the next interface from /proc/net/dev.
64
+  */
65
+-void get_next_iface(FILE * fd, char *ifname)
66
++int get_next_iface(FILE * fd, char *ifname, int n)
67
+ {
68
+     char buf[161];
69
+ 
70
++    strcpy(ifname, "");
71
++
72
+     if (!feof(fd)) {
73
+         strcpy(buf, "");
74
+         fgets(buf, 160, fd);
75
+-        if (strcmp(buf, "") != 0)
76
+-            strcpy(ifname, ltrim(strtok(buf, ":")));
77
+-        else
78
+-            strcpy(ifname, "");
79
+-    } else
80
+-        strcpy(ifname, "");
81
++        if (strcmp(buf, "") != 0) {
82
++            strncpy(ifname, ltrim(strtok(buf, ":")), n);
83
++            if (ifname[n - 1] != '\0')
84
++                strcpy(ifname, "");
85
++            return 1;
86
++        }
87
++    }
88
++    return 0;
89
+ }
90
+ 
91
+ /*
0 92
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+--- iptraf-3.0.0/src/iptraf.c.orig	2005-09-13 08:42:54.000000000 +0200
1
+@@ -39,6 +39,7 @@
2
+ #include <menurt.h>
3
+ #include <winops.h>
4
+ #include <msgboxes.h>
5
++#include <locale.h>
6
+ #include "dirs.h"
7
+ #include "deskman.h"
8
+ #include "fltdefs.h"
9
+@@ -499,6 +500,8 @@
10
+     }
11
+ #endif
12
+ 
13
++    setlocale(LC_ALL, "");
14
++
15
+     strcpy(current_logfile, "");
16
+     strcpy(graphing_logfile, "");
17
+     strcpy(graphing_filter, "");
0 18
new file mode 100644
... ...
@@ -0,0 +1,89 @@
0
+diff -up iptraf-3.0.1/src/tr.c.old iptraf-3.0.1/src/tr.c
1
+--- iptraf-3.0.1/src/tr.c.old	2005-09-13 08:42:54.000000000 +0200
2
+@@ -7,7 +7,7 @@
3
+  */
4
+ 
5
+ #include <asm/types.h>
6
+-#include <linux/if_tr.h>
7
++#include <netinet/if_tr.h>
8
+ #include <netinet/in.h>
9
+ 
10
+ unsigned int get_tr_ip_offset(unsigned char *pkt)
11
+diff -up iptraf-3.0.1/src/othptab.c.old iptraf-3.0.1/src/othptab.c
12
+--- iptraf-3.0.1/src/othptab.c.old	2007-09-25 11:47:35.000000000 +0200
13
+@@ -19,10 +19,10 @@ details.
14
+ #include <stdlib.h>
15
+ #include <asm/types.h>
16
+ #include <sys/socket.h>
17
+-#include <linux/if_ether.h>
18
+-#include <linux/if_tr.h>
19
+-#include <linux/netdevice.h>
20
+-#include <linux/if_fddi.h>
21
++#include <netinet/if_ether.h>
22
++#include <netinet/if_tr.h>
23
++#include <linux/netdevice.h>
24
++#include <netinet/if_fddi.h>
25
+ #include <winops.h>
26
+ #include "arphdr.h"
27
+ #include "options.h"
28
+diff -up iptraf-3.0.1/src/Makefile.old iptraf-3.0.1/src/Makefile
29
+--- iptraf-3.0.1/src/Makefile.old	2007-11-02 12:27:07.000000000 +0100
30
+@@ -18,7 +18,7 @@ VERSION 	= -DVERSION=\"$(VERNUMBER)\"
31
+ BINDIR		= ../../iptraf-$(VERNUMBER).bin.$(ARCH)
32
+ 
33
+ CC		= gcc
34
+-LIBS		= -L../support -ltextbox -lpanel -lncurses   # in this order!
35
++LIBS		= -L../support -ltextbox -lpanelw -lncursesw   # in this order!
36
+ 
37
+ # comment this one out to omit debug code when done.
38
+ 
39
+@@ -39,7 +39,7 @@ LDOPTS		= #-static
40
+ # you may want to change this to point to your ncurses include directory
41
+ # if the ncurses include files are not in the default location.
42
+ 
43
+-INCLUDEDIR	= -I/usr/include/ncurses -I../support
44
++INCLUDEDIR	= -I/usr/include/ncursesw -I../support
45
+ 
46
+ # You can uncomment this one to disable the backspace key in input fields.
47
+ # This means you must use the Del key or Ctrl+H combination to erase the
48
+@@ -162,7 +162,7 @@ install:
49
+ # and the compiled programs for release as a ready-to-run distribution.
50
+ 
51
+ dist-bin: all
52
+-	$(CC) $(LDOPTS) $(PROF) -o iptraf $(OBJS) -L../support -ltextbox /usr/lib/libpanel.a /usr/lib/libncurses.a
53
++	$(CC) $(LDOPTS) $(PROF) -o iptraf $(OBJS) -L../support -ltextbox /usr/lib/libpanelw.a /usr/lib/libncursesw.a
54
+ 	rm -rf $(BINDIR)
55
+ 	mkdir $(BINDIR)
56
+ 	/bin/cp -p ../CHANGES ../LICENSE ../FAQ ../INSTALL ../README* \
57
+@@ -178,7 +178,7 @@ dist-bin: all
58
+ # Just in case anyone needs to link a static binary
59
+ #
60
+ static: $(OBJS)
61
+-	$(CC) -static $(PROC) -o iptraf $(OBJS) ../support/libtextbox.a -lpanel -lncurses
62
++	$(CC) -static $(PROC) -o iptraf $(OBJS) ../support/libtextbox.a -lpanelw -lncursesw
63
+ 	$(CC) -static -o rvnamed rvnamed.o getpath.o
64
+ 	$(CC) -static -o rawtime rawtime.c
65
+ 
66
+diff -up iptraf-3.0.1/src/tcptable.h.old iptraf-3.0.1/src/tcptable.h
67
+--- iptraf-3.0.1/src/tcptable.h.old	2007-09-25 11:46:03.000000000 +0200
68
+@@ -20,11 +20,11 @@
69
+ #include <arpa/inet.h>
70
+ #include <net/if_arp.h>
71
+ #include <asm/types.h>
72
+-#include <linux/if_packet.h>
73
+-#include <linux/if_ether.h>
74
+-#include <linux/netdevice.h>
75
+-#include <linux/if_fddi.h>
76
+-#include <linux/if_tr.h>
77
++#include <linux/if_packet.h>
78
++#include <netinet/if_ether.h>
79
++#include <linux/netdevice.h>
80
++#include <netinet/if_fddi.h>
81
++#include <netinet/if_tr.h>
82
+ // #include <net/if.h>
83
+ #include <netinet/ip.h>
84
+ #include <netinet/udp.h>
0 85
new file mode 100644
... ...
@@ -0,0 +1,33 @@
0
+diff -up iptraf-3.0.1/src/ifstats.c.old iptraf-3.0.1/src/ifstats.c
1
+--- iptraf-3.0.1/src/ifstats.c.old	2007-11-02 12:49:25.000000000 +0100
2
+@@ -26,6 +26,7 @@ details.
3
+ #include <time.h>
4
+ #include <sys/time.h>
5
+ #include <sys/types.h>
6
++#include <linux/types.h>
7
+ #include <sys/socket.h>
8
+ #include <sys/ioctl.h>
9
+ #include <netinet/in.h>
10
+diff -up iptraf-3.0.1/src/serv.c.old iptraf-3.0.1/src/serv.c
11
+--- iptraf-3.0.1/src/serv.c.old	2007-11-02 12:50:04.000000000 +0100
12
+@@ -32,6 +32,7 @@ details.
13
+ #include <netinet/ip.h>
14
+ #include <netinet/ip6.h>
15
+ #include <netinet/udp.h>
16
++#include <linux/types.h>
17
+ #include <linux/if_packet.h>
18
+ #include <linux/if_ether.h>
19
+ #include <listbox.h>
20
+diff -up iptraf-3.0.1/src/ifaces.c.old iptraf-3.0.1/src/ifaces.c
21
+--- iptraf-3.0.1/src/ifaces.c.old	2007-11-02 12:50:37.000000000 +0100
22
+@@ -27,6 +27,7 @@ details.
23
+ #include <net/if.h>
24
+ #include <fcntl.h>
25
+ #include <string.h>
26
++#include <linux/types.h>
27
+ #include <linux/if_packet.h>
28
+ #include "links.h"
29
+ #include "error.h"
0 30
new file mode 100644
... ...
@@ -0,0 +1,86 @@
0
+--- iptraf-3.0.1/src/ifstats.c.ipv6-fix	2008-06-05 13:40:33.000000000 +0200
1
+@@ -294,7 +294,7 @@ void printifentry(struct iflist *ptmp, W
2
+     printlargenum(ptmp->ip6total, win);
3
+     wmove(win, target_row, 39 * COLS / 80);
4
+     printlargenum(ptmp->noniptotal, win);
5
+-    wmove(win, target_row, 29 * COLS / 80);
6
++    wmove(win, target_row, 49 * COLS / 80);
7
+     wprintw(win, "%8lu", ptmp->badtotal);
8
+ }
9
+ 
10
+@@ -329,10 +329,8 @@ void labelstats(WINDOW * win)
11
+     wmove(win, 0, 32 * COLS / 80);
12
+     wprintw(win, " IPv6 ");
13
+     wmove(win, 0, 42 * COLS / 80);
14
+-    wprintw(win, " IP ");
15
+-    wmove(win, 0, 36 * COLS / 80);
16
+     wprintw(win, " NonIP ");
17
+-    wmove(win, 0, 51 * COLS / 80);
18
++    wmove(win, 0, 52 * COLS / 80);
19
+     wprintw(win, " BadIP ");
20
+     wmove(win, 0, 65 * COLS / 80);
21
+     wprintw(win, " Activity ");
22
+--- iptraf-3.0.1/src/othptab.c.ipv6-fix	2008-06-05 13:42:10.000000000 +0200
23
+@@ -189,6 +189,11 @@ struct othptabent *add_othp_entry(struct
24
+                     ((struct icmphdr *) packet2)->type;
25
+                 new_entry->un.icmp.code =
26
+                     ((struct icmphdr *) packet2)->code;
27
++            } else if (protocol == IPPROTO_ICMPV6) {
28
++                new_entry->un.icmp6.type =
29
++                    ((struct icmp6_hdr *) packet2)->icmp6_type;
30
++                new_entry->un.icmp6.code =
31
++                    ((struct icmp6_hdr *) packet2)->icmp6_code;            	
32
+             } else if (protocol == IPPROTO_UDP) {
33
+                 servlook(servnames, ((struct udphdr *) packet2)->source,
34
+                          IPPROTO_UDP, new_entry->un.udp.s_sname, 10);
35
+@@ -565,8 +570,8 @@ void printothpentry(struct othptable *ta
36
+                 case ICMP6_DST_UNREACH_ADMIN:
37
+                     strcpy(additional, "admin");
38
+                     break;
39
+-                case ICMP6_DST_UNREACH_NOTNEIGHBOR:
40
+-                    strcpy(additional, "not neigh");
41
++                case ICMP6_DST_UNREACH_BEYONDSCOPE:
42
++                    strcpy(additional, "not beyondsp");
43
+                     break;
44
+                 case ICMP6_DST_UNREACH_ADDR:
45
+                     strcpy(additional, "unreach addr");
46
+@@ -576,15 +581,15 @@ void printothpentry(struct othptable *ta
47
+                     break;
48
+                 }
49
+                 break;
50
+-    	    case ICMP6_PACKET_TOO_BIG:
51
++            case ICMP6_PACKET_TOO_BIG:
52
+             	strcpy(description, "pkt too big");
53
+                 break;
54
+-	    case ICMP6_TIME_EXCEEDED:
55
+-    	        strcpy(description, "time exceeded");
56
+-    		break;
57
++            case ICMP6_TIME_EXCEEDED:
58
++                strcpy(description, "time exceeded");
59
++                break;
60
+             case ICMP6_PARAM_PROB:
61
+-	        strcpy(description, "param prob");
62
+-    	        break;
63
++                strcpy(description, "param prob");
64
++                break;
65
+             case ICMP6_ECHO_REQUEST:
66
+                 strcpy(description, "echo req");
67
+                 break;
68
+@@ -597,15 +602,6 @@ void printothpentry(struct othptable *ta
69
+             case ND_ROUTER_ADVERT:
70
+                 strcpy(description, "router adv");
71
+                 break;
72
+-            case ICMP6_MEMBERSHIP_QUERY:
73
+-                strcpy(description, "mbrship query");
74
+-                break;
75
+-            case ICMP6_MEMBERSHIP_REPORT:
76
+-                strcpy(description, "mbrship report");
77
+-                break;
78
+-            case ICMP6_MEMBERSHIP_REDUCTION:
79
+-                strcpy(description, "mbrship reduc");
80
+-                break;
81
+             case ND_NEIGHBOR_SOLICIT:
82
+                 strcpy(description, "neigh sol");
83
+                 break;
0 84
new file mode 100644
... ...
@@ -0,0 +1,1450 @@
0
+diff -up iptraf-3.0.1/src/attrs.h.ipv6 iptraf-3.0.1/src/attrs.h
1
+--- iptraf-3.0.1/src/attrs.h.ipv6	2005-09-13 08:42:54.000000000 +0200
2
+@@ -29,3 +29,5 @@ extern int ARPATTR;
3
+ extern int GREATTR;
4
+ extern int UNKNIPATTR;
5
+ extern int UNKNATTR;
6
++extern int IPV6ATTR;
7
++extern int ICMPV6ATTR;
8
+diff -up iptraf-3.0.1/src/deskman.c.ipv6 iptraf-3.0.1/src/deskman.c
9
+--- iptraf-3.0.1/src/deskman.c.ipv6	2005-09-13 08:42:54.000000000 +0200
10
+@@ -56,7 +56,8 @@ int GREATTR;
11
+ int ARPATTR;
12
+ int UNKNIPATTR;
13
+ int UNKNATTR;
14
+-
15
++int IPV6ATTR;
16
++int ICMPV6ATTR;
17
+ 
18
+ /*  draw the basic desktop common to my screen-oriented programs */
19
+ 
20
+@@ -89,7 +90,8 @@ void about()
21
+     PANEL *panel;
22
+     int ch;
23
+ 
24
+-    win = newwin(15, 50, (LINES - 15) / 2, (COLS - 50) / 2);
25
++    win = newwin(18, 62, (LINES - 17) / 2, (COLS - 62) / 2);
26
++
27
+     panel = new_panel(win);
28
+ 
29
+     tx_stdwinset(win);
30
+@@ -108,9 +110,12 @@ void about()
31
+     mvwprintw(win, 10, 2,
32
+               "Public License Version 2 or any later version.");
33
+     mvwprintw(win, 11, 2, "See the included LICENSE file for details.");
34
++    mvwprintw(win, 13, 2, "IPv6 support by Markus Ullmann <mail@markus-ullmann.de>");
35
++    mvwprintw(win, 14, 2, "inspired by 2.7.0 diff by Guy Martin <gmsoft@tuxicoman.be>");
36
+ 
37
+     wattrset(win, HIGHATTR);
38
+-    mvwprintw(win, 13, 2, ANYKEY_MSG);
39
++
40
++    mvwprintw(win, 16, 2, ANYKEY_MSG);
41
+ 
42
+     update_panels();
43
+     doupdate();
44
+@@ -252,6 +257,8 @@ void standardcolors(int color)
45
+         ARPATTR = COLOR_PAIR(5) | A_BOLD;
46
+         GREATTR = COLOR_PAIR(1);
47
+         UNKNIPATTR = COLOR_PAIR(19) | A_BOLD;
48
++	ICMPV6ATTR = COLOR_PAIR(19) | A_BOLD;
49
++	IPV6ATTR = COLOR_PAIR(19);
50
+         UNKNATTR = COLOR_PAIR(4) | A_BOLD;
51
+     } else {
52
+         STDATTR = A_REVERSE;
53
+@@ -281,6 +288,7 @@ void standardcolors(int color)
54
+         ARPATTR = A_BOLD;
55
+         GREATTR = A_BOLD;
56
+         UNKNIPATTR = A_BOLD;
57
++	ICMPV6ATTR = A_REVERSE;
58
+         UNKNATTR = A_BOLD;
59
+     }
60
+ 
61
+diff -up iptraf-3.0.1/src/ifstats.c.ipv6 iptraf-3.0.1/src/ifstats.c
62
+--- iptraf-3.0.1/src/ifstats.c.ipv6	2005-09-13 08:42:54.000000000 +0200
63
+@@ -1,4 +1,3 @@
64
+-
65
+ /***
66
+ 
67
+ ifstats.c	- the interface statistics module
68
+@@ -34,6 +33,7 @@ details.
69
+ #include <linux/if_packet.h>
70
+ #include <net/if.h>
71
+ #include <netinet/ip.h>
72
++#include <netinet/ip6.h>
73
+ #include <netinet/tcp.h>
74
+ #include <netinet/udp.h>
75
+ #include <linux/if_ether.h>
76
+@@ -252,7 +252,7 @@ void updaterates(struct iftab *table, in
77
+ 
78
+     wattrset(table->statwin, HIGHATTR);
79
+     do {
80
+-        wmove(table->statwin, ptmp->index - idx, 52 * COLS / 80);
81
++	wmove(table->statwin, ptmp->index - idx, 60 * COLS / 80);
82
+         if (unit == KBITS) {
83
+             ptmp->rate =
84
+                 ((float) (ptmp->spanbr * 8 / 1000)) /
85
+@@ -286,13 +286,15 @@ void printifentry(struct iflist *ptmp, W
86
+     wmove(win, target_row, 1);
87
+     wprintw(win, "%s", ptmp->ifname);
88
+     wattrset(win, HIGHATTR);
89
+-    wmove(win, target_row, 12 * COLS / 80);
90
++    wmove(win, target_row, 9  * COLS / 80);
91
+     printlargenum(ptmp->total, win);
92
+-    wmove(win, target_row, 22 * COLS / 80);
93
++    wmove(win, target_row, 19 * COLS / 80);
94
+     printlargenum(ptmp->iptotal, win);
95
+-    wmove(win, target_row, 32 * COLS / 80);
96
++    wmove(win, target_row, 29 * COLS / 80);
97
++    printlargenum(ptmp->ip6total, win);
98
++    wmove(win, target_row, 39 * COLS / 80);
99
+     printlargenum(ptmp->noniptotal, win);
100
+-    wmove(win, target_row, 42 * COLS / 80);
101
++    wmove(win, target_row, 29 * COLS / 80);
102
+     wprintw(win, "%8lu", ptmp->badtotal);
103
+ }
104
+ 
105
+@@ -320,15 +322,19 @@ void labelstats(WINDOW * win)
106
+ {
107
+     wmove(win, 0, 1);
108
+     wprintw(win, " Iface ");
109
+-    wmove(win, 0, 16 * COLS / 80);
110
++    wmove(win, 0, 12 * COLS / 80);
111
+     wprintw(win, " Total ");
112
+-    wmove(win, 0, 29 * COLS / 80);
113
++    wmove(win, 0, 22 * COLS / 80);
114
++    wprintw(win, " IPv4 ");
115
++    wmove(win, 0, 32 * COLS / 80);
116
++    wprintw(win, " IPv6 ");
117
++    wmove(win, 0, 42 * COLS / 80);
118
+     wprintw(win, " IP ");
119
+     wmove(win, 0, 36 * COLS / 80);
120
+     wprintw(win, " NonIP ");
121
+-    wmove(win, 0, 45 * COLS / 80);
122
++    wmove(win, 0, 51 * COLS / 80);
123
+     wprintw(win, " BadIP ");
124
+-    wmove(win, 0, 55 * COLS / 80);
125
++    wmove(win, 0, 65 * COLS / 80);
126
+     wprintw(win, " Activity ");
127
+ }
128
+ 
129
+@@ -422,6 +428,8 @@ void ifstats(const struct OPTIONS *optio
130
+     char *packet;
131
+     int pkt_result = 0;
132
+ 
133
++    unsigned int iphlen;
134
++
135
+     struct sockaddr_ll fromaddr;
136
+     unsigned short linktype;
137
+ 
138
+@@ -590,6 +598,18 @@ void ifstats(const struct OPTIONS *optio
139
+                     && pkt_result != MORE_FRAGMENTS)
140
+                     continue;
141
+ 
142
++		if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
143
++                    && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
144
++	                iphlen = ((struct iphdr *) packet)->ihl * 4;
145
++    	                fromaddr.sll_protocol = htons(ETH_P_IPV6);
146
++        	        memmove(buf, buf + iphlen, MAX_PACKET_SIZE - iphlen);
147
++            	        // Reprocess the IPv6 packet
148
++                        pkt_result = processpacket(buf, &packet, &br, NULL, NULL, NULL,
149
++                                  &fromaddr, &linktype, ofilter, MATCH_OPPOSITE_USECONFIG, ifname, NULL);
150
++	                if (pkt_result != PACKET_OK
151
++    	                && pkt_result != MORE_FRAGMENTS)
152
++        	        continue;
153
++    	        }
154
+                 positionptr(&table, &ptmp, ifname);
155
+ 
156
+                 ptmp->total++;
157
+@@ -604,6 +624,8 @@ void ifstats(const struct OPTIONS *optio
158
+                         (ptmp->badtotal)++;
159
+                         continue;
160
+                     }
161
++                } else if (fromaddr.sll_protocol == ETH_P_IPV6) {
162
++                    ptmp->ip6total++;
163
+                 } else {
164
+                     (ptmp->noniptotal)++;
165
+                 }
166
+@@ -654,19 +676,20 @@ void printdetlabels(WINDOW * win, struct
167
+               "Packets      Bytes     Packets      Bytes     Packets      Bytes");
168
+     wattrset(win, STDATTR);
169
+     mvwprintw(win, 4, 2, "Total:");
170
+-    mvwprintw(win, 5, 2, "IP:");
171
+-    mvwprintw(win, 6, 2, "TCP:");
172
+-    mvwprintw(win, 7, 2, "UDP:");
173
+-    mvwprintw(win, 8, 2, "ICMP:");
174
+-    mvwprintw(win, 9, 2, "Other IP:");
175
+-    mvwprintw(win, 10, 2, "Non-IP:");
176
+-    mvwprintw(win, 13, 2, "Total rates:");
177
+-    mvwprintw(win, 16, 2, "Incoming rates:");
178
+-    mvwprintw(win, 19, 2, "Outgoing rates:");
179
+-
180
+-    mvwprintw(win, 13, 45, "Broadcast packets:");
181
+-    mvwprintw(win, 14, 45, "Broadcast bytes:");
182
+-    mvwprintw(win, 18, 45, "IP checksum errors:");
183
++    mvwprintw(win, 5, 2, "IPv4:");
184
++    mvwprintw(win, 6, 2, "IPv6:");
185
++    mvwprintw(win, 7, 2, "TCP:");
186
++    mvwprintw(win, 8, 2, "UDP:");
187
++    mvwprintw(win, 9, 2, "ICMP:");
188
++    mvwprintw(win, 10, 2, "Other IP:");
189
++    mvwprintw(win, 11, 2, "Non-IP:");
190
++    mvwprintw(win, 14, 2, "Total rates:");
191
++    mvwprintw(win, 17, 2, "Incoming rates:");
192
++    mvwprintw(win, 20, 2, "Outgoing rates:");
193
++
194
++    mvwprintw(win, 14, 45, "Broadcast packets:");
195
++    mvwprintw(win, 15, 45, "Broadcast bytes:");
196
++    mvwprintw(win, 19, 45, "IP checksum errors:");
197
+ 
198
+     update_panels();
199
+     doupdate();
200
+@@ -707,38 +730,41 @@ void printdetails(struct iftotals *total
201
+                  totals->iptotal_in, totals->ipbtotal_in,
202
+                  totals->iptotal_out, totals->ipbtotal_out);
203
+ 
204
+-    printstatrow(win, 6, totals->tcptotal, totals->tcpbtotal,
205
++    printstatrow(win, 6, totals->ip6total, totals->ip6btotal,
206
++                 totals->ip6total_in, totals->ip6btotal_in,
207
++                 totals->ip6total_out, totals->ip6btotal_out);  
208
++  
209
++    printstatrow(win, 7, totals->tcptotal, totals->tcpbtotal,
210
+                  totals->tcptotal_in, totals->tcpbtotal_in,
211
+-                 totals->tcptotal_out, totals->tcpbtotal_out);
212
++		 totals->tcptotal_out, totals->tcpbtotal_out);
213
+ 
214
+-    printstatrow(win, 7, totals->udptotal, totals->udpbtotal,
215
++    printstatrow(win, 8, totals->udptotal, totals->udpbtotal,
216
+                  totals->udptotal_in, totals->udpbtotal_in,
217
+                  totals->udptotal_out, totals->udpbtotal_out);
218
+ 
219
+-    printstatrow(win, 8, totals->icmptotal, totals->icmpbtotal,
220
++    printstatrow(win, 9, totals->icmptotal, totals->icmpbtotal,
221
+                  totals->icmptotal_in, totals->icmpbtotal_in,
222
+                  totals->icmptotal_out, totals->icmpbtotal_out);
223
+ 
224
+-    printstatrow(win, 9, totals->othtotal, totals->othbtotal,
225
++    printstatrow(win, 10, totals->othtotal, totals->othbtotal,
226
+                  totals->othtotal_in, totals->othbtotal_in,
227
+                  totals->othtotal_out, totals->othbtotal_out);
228
+ 
229
+     /* Print non-IP totals */
230
+ 
231
+-    printstatrow(win, 10, totals->noniptotal, totals->nonipbtotal,
232
++    printstatrow(win, 11, totals->noniptotal, totals->nonipbtotal,
233
+                  totals->noniptotal_in, totals->nonipbtotal_in,
234
+                  totals->noniptotal_out, totals->nonipbtotal_out);
235
+ 
236
+     /* Broadcast totals */
237
+-
238
+-    wmove(win, 13, 67);
239
+-    printlargenum(totals->bcast, win);
240
+     wmove(win, 14, 67);
241
++    printlargenum(totals->bcast, win);
242
++    wmove(win, 15, 67);
243
+     printlargenum(totals->bcastbytes, win);
244
+ 
245
+     /* Bad packet count */
246
+ 
247
+-    mvwprintw(win, 18, 68, "%8lu", totals->badtotal);
248
++    mvwprintw(win, 19, 68, "%8lu", totals->badtotal);
249
+ }
250
+ 
251
+ 
252
+@@ -757,6 +783,7 @@ void detstats(char *iface, const struct 
253
+     char buf[MAX_PACKET_SIZE];
254
+     char *packet;
255
+     struct iphdr *ipacket = NULL;
256
++    struct ip6_hdr *ip6packet = NULL;
257
+     char *tpacket;
258
+     unsigned int iphlen;
259
+ 
260
+@@ -962,15 +989,15 @@ void detstats(char *iface, const struct 
261
+             starttime = now;
262
+ 
263
+             wattrset(statwin, HIGHATTR);
264
+-            mvwprintw(statwin, 13, 19, "%8.1f %s/sec", activity,
265
++            mvwprintw(statwin, 14, 19, "%8.1f %s/sec", activity,
266
+                       unitstring);
267
+-            mvwprintw(statwin, 14, 19, "%8.1f packets/sec", pps);
268
+-            mvwprintw(statwin, 16, 19, "%8.1f %s/sec", activity_in,
269
++            mvwprintw(statwin, 15, 19, "%8.1f packets/sec", pps);
270
++            mvwprintw(statwin, 17, 19, "%8.1f %s/sec", activity_in,
271
+                       unitstring);
272
+-            mvwprintw(statwin, 17, 19, "%8.1f packets/sec", pps_in);
273
+-            mvwprintw(statwin, 19, 19, "%8.1f %s/sec", activity_out,
274
++            mvwprintw(statwin, 18, 19, "%8.1f packets/sec", pps_in);
275
++            mvwprintw(statwin, 20, 19, "%8.1f %s/sec", activity_out,
276
+                       unitstring);
277
+-            mvwprintw(statwin, 20, 19, "%8.1f packets/sec", pps_out);
278
++            mvwprintw(statwin, 21, 19, "%8.1f packets/sec", pps_out);
279
+ 
280
+             if (activity > peakactivity)
281
+                 peakactivity = activity;
282
+@@ -1077,6 +1104,18 @@ void detstats(char *iface, const struct 
283
+             if (pkt_result != PACKET_OK && pkt_result != MORE_FRAGMENTS)
284
+                 continue;
285
+ 
286
++            if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
287
++                && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
288
++                    iphlen = ((struct iphdr *) packet)->ihl * 4;
289
++                    fromaddr.sll_protocol = htons(ETH_P_IPV6);
290
++                    memmove(buf, buf + iphlen, MAX_PACKET_SIZE - iphlen);
291
++                    // Reprocess the IPv6 packet
292
++                    pkt_result = processpacket(buf, &packet, &br, NULL, NULL, NULL,
293
++                              &fromaddr, &linktype, ofilter, MATCH_OPPOSITE_USECONFIG, ifname, NULL);
294
++                    if (pkt_result != PACKET_OK && pkt_result != MORE_FRAGMENTS)
295
++                        continue;
296
++            }
297
++
298
+             totals.total++;
299
+             totals.bytestotal += framelen;
300
+ 
301
+@@ -1185,8 +1224,73 @@ void detstats(char *iface, const struct 
302
+                     }
303
+                     break;
304
+                 }
305
++            } else if (fromaddr.sll_protocol == ETH_P_IPV6) {
306
++ 
307
++                ip6packet = (struct ip6_hdr *) packet;
308
++                iplen = ntohs(ip6packet->ip6_plen);
309
++ 
310
++                totals.ip6total++;
311
++                totals.ip6btotal += iplen;
312
++ 
313
++                if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
314
++                    totals.ip6total_out++;
315
++                    totals.ip6btotal_out += iplen;
316
++                } else {
317
++                    totals.ip6total_in++;
318
++                    totals.ip6btotal_in += iplen;
319
++                }
320
++ 
321
++                switch (ip6packet->ip6_nxt) {
322
++                case IPPROTO_TCP:
323
++                    totals.tcptotal++;
324
++                    totals.tcpbtotal += iplen;
325
++ 
326
++                    if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
327
++                        totals.tcptotal_out++;
328
++                        totals.tcpbtotal_out += iplen;
329
++                    } else {
330
++                        totals.tcptotal_in++;
331
++                        totals.tcpbtotal_in += iplen;
332
++                    }
333
++                    break;
334
++                case IPPROTO_UDP:
335
++                    totals.udptotal++;
336
++                    totals.udpbtotal += iplen;
337
++ 
338
++                    if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
339
++                        totals.udptotal_out++;
340
++                        totals.udpbtotal_out += iplen;
341
++                    } else {
342
++                        totals.udptotal_in++;
343
++                        totals.udpbtotal_in += iplen;
344
++                    }
345
++                    break;
346
++                case IPPROTO_ICMPV6:
347
++                    totals.icmptotal++;
348
++                    totals.icmpbtotal += iplen;
349
++                    if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
350
++                        totals.icmptotal_out++;
351
++                        totals.icmpbtotal_out += iplen;
352
++                    } else {
353
++                        totals.icmptotal_in++;
354
++                        totals.icmpbtotal_in += iplen;
355
++                    }
356
++                    break;
357
++                default:
358
++                    totals.othtotal++;
359
++                    totals.othbtotal += iplen;
360
++ 
361
++                    if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
362
++                        totals.othtotal_out++;
363
++                        totals.othbtotal_out += iplen;
364
++                    } else {
365
++                        totals.othtotal_in++;
366
++                	totals.othbtotal_in += iplen;
367
++                    }
368
++            	    break;
369
++                }
370
+             } else {
371
+-                totals.noniptotal++;
372
++		 totals.noniptotal++;
373
+                 totals.nonipbtotal += br;
374
+ 
375
+                 if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
376
+diff -up iptraf-3.0.1/src/ifstats.h.ipv6 iptraf-3.0.1/src/ifstats.h
377
+--- iptraf-3.0.1/src/ifstats.h.ipv6	2005-09-13 08:42:54.000000000 +0200
378
+@@ -9,6 +9,7 @@ struct iflist {
379
+     char ifname[8];
380
+     unsigned int encap;
381
+     unsigned long long iptotal;
382
++    unsigned long long ip6total;
383
+     unsigned long badtotal;
384
+     unsigned long long noniptotal;
385
+     unsigned long long total;
386
+@@ -49,6 +50,13 @@ struct iftotals {
387
+     unsigned long long ipbtotal_in;
388
+     unsigned long long ipbtotal_out;
389
+ 
390
++    unsigned long long ip6total;
391
++    unsigned long long ip6btotal;
392
++    unsigned long long ip6total_in;
393
++    unsigned long long ip6total_out;
394
++    unsigned long long ip6btotal_in;
395
++    unsigned long long ip6btotal_out;
396
++
397
+     unsigned long long noniptotal;
398
+     unsigned long long nonipbtotal;
399
+     unsigned long long noniptotal_in;
400
+diff -up iptraf-3.0.1/src/itrafmon.c.ipv6 iptraf-3.0.1/src/itrafmon.c
401
+--- iptraf-3.0.1/src/itrafmon.c.ipv6	2005-09-13 08:42:54.000000000 +0200
402
+@@ -23,6 +23,8 @@ details.
403
+ #include <ctype.h>
404
+ #include <winops.h>
405
+ #include <labels.h>
406
++#include <netinet/ip6.h>
407
++#include <netinet/icmp6.h>
408
+ #include "options.h"
409
+ #include "tcptable.h"
410
+ #include "othptab.h"
411
+@@ -578,6 +580,9 @@ void ipmon(struct OPTIONS *options,
412
+     char tpacket[MAX_PACKET_SIZE];      /* raw packet data */
413
+     char *packet = NULL;        /* network packet ptr */
414
+     struct iphdr *ippacket;
415
++    struct ip6_hdr *ip6packet;
416
++    unsigned int protocol;
417
++    unsigned int frag_off;
418
+     struct tcphdr *transpacket; /* IP-encapsulated packet */
419
+     unsigned int sport = 0, dport = 0;  /* TCP/UDP port values */
420
+     char sp_buf[10];
421
+@@ -1046,9 +1051,9 @@ void ipmon(struct OPTIONS *options,
422
+             if (pkt_result != PACKET_OK)
423
+                 continue;
424
+ 
425
+-            if (fromaddr.sll_protocol != ETH_P_IP) {
426
++            if ((fromaddr.sll_protocol != ETH_P_IP) && (fromaddr.sll_protocol != ETH_P_IPV6)) {
427
+                 othpent = add_othp_entry(&othptbl, &table,
428
+-                                         0, 0, NOT_IP,
429
++                                         0, 0, NULL, NULL, NOT_IP,
430
+                                          fromaddr.sll_protocol,
431
+                                          linktype, (char *) tpacket,
432
+                                          (char *) packet, br, ifname, 0, 0,
433
+@@ -1056,23 +1061,52 @@ void ipmon(struct OPTIONS *options,
434
+                                          options->servnames, 0, &nomem);
435
+                 continue;
436
+             } else {
437
++                if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
438
++                    && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
439
++                        iphlen = ((struct iphdr *) packet)->ihl * 4;
440
++                        fromaddr.sll_protocol = htons(ETH_P_IPV6);
441
++                        memmove(tpacket, tpacket + iphlen, MAX_PACKET_SIZE - iphlen);
442
++                        // Reprocess the ipv6 packet
443
++                        pkt_result = processpacket((char *) tpacket, &packet, &readlen,
444
++                                        &br, &sport, &dport, &fromaddr,
445
++                                        &linktype, ofilter, MATCH_OPPOSITE_ALWAYS, ifname, ifptr);
446
++                        if (pkt_result != PACKET_OK)
447
++                            continue;
448
++                }
449
++                if (fromaddr.sll_protocol == ETH_P_IP) {
450
+                 ippacket = (struct iphdr *) packet;
451
+                 iphlen = ippacket->ihl * 4;
452
++                    ip6packet = NULL;
453
++                    protocol = ippacket->protocol;
454
++                    frag_off = ippacket->frag_off;
455
++                } else {
456
++                    ip6packet = (struct ip6_hdr *) packet;
457
++                    iphlen = 40;
458
++                    ippacket = NULL;
459
++                    protocol = ip6packet->ip6_nxt;
460
++                    frag_off = 0;
461
++                }
462
+                 transpacket = (struct tcphdr *) (packet + iphlen);
463
+ 
464
+-                if (ippacket->protocol == IPPROTO_TCP) {
465
++        	if (protocol == IPPROTO_TCP) {
466
+ 
467
++                if (ippacket != NULL)
468
+                     tcpentry =
469
+                         in_table(&table, ippacket->saddr, ippacket->daddr,
470
+-                                 ntohs(sport), ntohs(dport), ifname,
471
+-                                 logging, logfile, &nomem, options);
472
++                            NULL , NULL,
473
++                            ntohs(sport), ntohs(dport), ifname,
474
++                            logging, logfile, &nomem, options);
475
++               else
476
++                   tcpentry = in_table(&table, 0, 0, (uint8_t*)(&ip6packet->ip6_src.s6_addr), (uint8_t*)(&ip6packet->ip6_dst.s6_addr),
477
++                             ntohs(sport), ntohs(dport), ifname,
478
++                             logging, logfile, &nomem, options);
479
+ 
480
+                     /* 
481
+                      * Add a new entry if it doesn't exist, and, 
482
+                      * to reduce the chances of stales, not a FIN.
483
+                      */
484
+ 
485
+-                    if ((ntohs(ippacket->frag_off) & 0x3fff) == 0) {    /* first frag only */
486
++                    if ((ntohs(frag_off) & 0x3fff) == 0) {  /* first frag only */
487
+                         totalhlen = iphlen + transpacket->doff * 4;
488
+ 
489
+                         if ((tcpentry == NULL) && (!(transpacket->fin))) {
490
+@@ -1084,17 +1118,26 @@ void ipmon(struct OPTIONS *options,
491
+ 
492
+                             if (!nomem) {
493
+                                 wasempty = (table.head == NULL);
494
++                                if (ippacket != NULL)
495
+                                 tcpentry = addentry(&table, (unsigned long)
496
+                                                     ippacket->saddr,
497
+                                                     (unsigned long)
498
+-                                                    ippacket->daddr, sport,
499
++                                                    ippacket->daddr,
500
++                                                    NULL, NULL, sport,
501
+                                                     dport,
502
+                                                     ippacket->protocol,
503
+                                                     ifname, &revlook,
504
+                                                     rvnfd,
505
+                                                     options->servnames,
506
+                                                     &nomem);
507
+-
508
++                                else
509
++                                    tcpentry = addentry(&table, 0, 0,
510
++                                                 (uint8_t*)(&ip6packet->ip6_src.s6_addr),
511
++                                                 (uint8_t*)(&ip6packet->ip6_dst.s6_addr),
512
++                                                 sport, dport, ip6packet->ip6_nxt,
513
++                                                 ifname, &revlook,
514
++                                                 rvnfd, options->servnames,
515
++                                                 &nomem);
516
+                                 if (tcpentry != NULL) {
517
+                                     printentry(&table,
518
+                                                tcpentry->oth_connection,
519
+@@ -1152,12 +1195,18 @@ void ipmon(struct OPTIONS *options,
520
+                                 p_sstat = tcpentry->s_fstat;
521
+                                 p_dstat = tcpentry->d_fstat;
522
+                             }
523
++                            if (ippacket != NULL)
524
+                             updateentry(&table, tcpentry, transpacket,
525
+                                         tpacket, linktype, readlen, br,
526
+                                         ippacket->frag_off, logging,
527
+                                         &revlook, rvnfd, options, logfile,
528
+                                         &nomem);
529
+-
530
++                            else
531
++                            updateentry(&table, tcpentry, transpacket, tpacket,
532
++                                     linktype, readlen,
533
++                                     readlen, 0, logging,
534
++                                     &revlook, rvnfd, options, logfile,
535
++                                     &nomem);
536
+                             /*
537
+                              * Log first packet of a TCP connection except if
538
+                              * it's a RST, which was already logged earlier in
539
+@@ -1213,7 +1262,7 @@ void ipmon(struct OPTIONS *options,
540
+                                            screen_idx, mode);
541
+                         }
542
+                     }
543
+-                } else {        /* now for the other IP protocols */
544
++            	} else if (ippacket != NULL) {
545
+                     fragment = ((ntohs(ippacket->frag_off) & 0x1fff) != 0);
546
+ 
547
+                     if (ippacket->protocol == IPPROTO_ICMP) {
548
+@@ -1234,7 +1283,7 @@ void ipmon(struct OPTIONS *options,
549
+ 
550
+                     othpent =
551
+                         add_othp_entry(&othptbl, &table, ippacket->saddr,
552
+-                                       ippacket->daddr, IS_IP,
553
++                                       ippacket->daddr, NULL, NULL, IS_IP,
554
+                                        ippacket->protocol, linktype,
555
+                                        (char *) tpacket,
556
+                                        (char *) transpacket, readlen,
557
+@@ -1242,6 +1291,21 @@ void ipmon(struct OPTIONS *options,
558
+                                        options->timeout, logging, logfile,
559
+                                        options->servnames, fragment,
560
+                                        &nomem);
561
++
562
++            } else {
563
++                if (ip6packet->ip6_nxt == IPPROTO_ICMPV6) {
564
++            	    if (((struct icmp6_hdr *) transpacket)->icmp6_type == ICMP6_DST_UNREACH)
565
++                        process_dest_unreach(&table, (char *) transpacket,
566
++                            ifname, &nomem);
567
++                }
568
++                othpent =
569
++                    add_othp_entry(&othptbl, &table, 0, 0, &ip6packet->ip6_src,
570
++                                   &ip6packet->ip6_dst, IS_IP,
571
++                                   ip6packet->ip6_nxt, linktype,
572
++                                   (char *) tpacket, (char *) transpacket,
573
++                                   readlen, ifname, &revlook,
574
++                                   rvnfd, options->timeout, logging, logfile,
575
++                                   options->servnames, fragment, &nomem);
576
+                 }
577
+             }
578
+         }
579
+diff -up iptraf-3.0.1/src/landesc.c.ipv6 iptraf-3.0.1/src/landesc.c
580
+--- iptraf-3.0.1/src/landesc.c.ipv6	2005-09-13 08:42:54.000000000 +0200
581
+@@ -208,7 +208,7 @@ void savedesclist(struct desclist *list,
582
+     else if (linktype == LINK_FDDI)
583
+         fd = fopen(FDDIFILE, "w");
584
+ 
585
+-    if (fd < 0) {
586
++    if (fd <= 0) {
587
+         etherr();
588
+         return;
589
+     }
590
+diff -up iptraf-3.0.1/src/options.c.ipv6 iptraf-3.0.1/src/options.c
591
+--- iptraf-3.0.1/src/options.c.ipv6	2005-09-13 08:42:54.000000000 +0200
592
+@@ -41,7 +41,7 @@ details.
593
+ 
594
+ void makeoptionmenu(struct MENU *menu)
595
+ {
596
+-    tx_initmenu(menu, 19, 40, (LINES - 19) / 2 - 1, (COLS - 40) / 16,
597
++    tx_initmenu(menu, 20, 40, (LINES - 19) / 2 - 1, (COLS - 40) / 16,
598
+                 BOXATTR, STDATTR, HIGHATTR, BARSTDATTR, BARHIGHATTR,
599
+                 DESCATTR);
600
+     tx_additem(menu, " ^R^everse DNS lookups",
601
+@@ -58,6 +58,8 @@ void makeoptionmenu(struct MENU *menu)
602
+                "Toggles activity indicators between kbits/s and kbytes/s");
603
+     tx_additem(menu, " Source ^M^AC addrs in traffic monitor",
604
+                "Toggles display of source MAC addresses in the IP Traffic Monitor");
605
++    tx_additem(menu, " ^S^how v6-in-v4 traffic as IPv6",
606
++               "Toggled display of IPv6 tunnel in IPv4 as IPv6 traffic");
607
+     tx_additem(menu, NULL, NULL);
608
+     tx_additem(menu, " ^T^imers...", "Configures timeouts and intervals");
609
+     tx_additem(menu, NULL, NULL);
610
+@@ -131,6 +133,8 @@ void indicatesetting(int row, struct OPT
611
+     case 7:
612
+         printoptonoff(options->mac, win);
613
+         break;
614
++    case 8:
615
++        printoptonoff(options->v6inv4asv6, win);
616
+     }
617
+ 
618
+ }
619
+@@ -168,6 +172,7 @@ void setdefaultopts(struct OPTIONS *opti
620
+     options->logspan = 3600;
621
+     options->updrate = 0;
622
+     options->closedint = 0;
623
++    options->v6inv4asv6 = 1;
624
+ }
625
+ 
626
+ void loadoptions(struct OPTIONS *options)
627
+@@ -189,17 +194,17 @@ void loadoptions(struct OPTIONS *options
628
+ void updatetimes(struct OPTIONS *options, WINDOW * win)
629
+ {
630
+     wattrset(win, HIGHATTR);
631
+-    mvwprintw(win, 9, 25, "%3u mins", options->timeout);
632
+-    mvwprintw(win, 10, 25, "%3u mins", options->logspan / 60);
633
+-    mvwprintw(win, 11, 25, "%3u secs", options->updrate);
634
+-    mvwprintw(win, 12, 25, "%3u mins", options->closedint);
635
++    mvwprintw(win, 10, 25, "%3u mins", options->timeout);
636
++    mvwprintw(win, 11, 25, "%3u mins", options->logspan / 60);
637
++    mvwprintw(win, 12, 25, "%3u secs", options->updrate);
638
++    mvwprintw(win, 13, 25, "%3u mins", options->closedint);
639
+ }
640
+ 
641
+ void showoptions(struct OPTIONS *options, WINDOW * win)
642
+ {
643
+     int i;
644
+ 
645
+-    for (i = 1; i <= 7; i++)
646
++    for (i = 1; i <= 8; i++)
647
+         indicatesetting(i, options, win);
648
+ 
649
+     updatetimes(options, win);
650
+@@ -272,13 +277,13 @@ void setoptions(struct OPTIONS *options,
651
+     }
652
+     makeoptionmenu(&menu);
653
+ 
654
+-    statwin = newwin(14, 35, (LINES - 19) / 2 - 1, (COLS - 40) / 16 + 40);
655
++    statwin = newwin(15, 35, (LINES - 19) / 2 - 1, (COLS - 40) / 16 + 40);
656
+     statpanel = new_panel(statwin);
657
+ 
658
+     wattrset(statwin, BOXATTR);
659
+     tx_colorwin(statwin);
660
+     tx_box(statwin, ACS_VLINE, ACS_HLINE);
661
+-    wmove(statwin, 8, 1);
662
++    wmove(statwin, 9, 1);
663
+     whline(statwin, ACS_HLINE, 33);
664
+     mvwprintw(statwin, 0, 1, " Current Settings ");
665
+     wattrset(statwin, STDATTR);
666
+@@ -289,10 +294,11 @@ void setoptions(struct OPTIONS *options,
667
+     mvwprintw(statwin, 5, 2, "Logging:");
668
+     mvwprintw(statwin, 6, 2, "Activity mode:");
669
+     mvwprintw(statwin, 7, 2, "MAC addresses:");
670
+-    mvwprintw(statwin, 9, 2, "TCP timeout:");
671
+-    mvwprintw(statwin, 10, 2, "Log interval:");
672
+-    mvwprintw(statwin, 11, 2, "Update interval:");
673
+-    mvwprintw(statwin, 12, 2, "Closed/idle persist:");
674
++    mvwprintw(statwin, 8, 2, "v6-in-v4 as IPv6:");
675
++    mvwprintw(statwin, 10, 2, "TCP timeout:");
676
++    mvwprintw(statwin, 11, 2, "Log interval:");
677
++    mvwprintw(statwin, 12, 2, "Update interval:");
678
++    mvwprintw(statwin, 13, 2, "Closed/idle persist:");
679
+     showoptions(options, statwin);
680
+ 
681
+     do {
682
+@@ -321,7 +327,10 @@ void setoptions(struct OPTIONS *options,
683
+         case 7:
684
+             options->mac = ~(options->mac);
685
+             break;
686
+-        case 9:
687
++        case 8:
688
++            options->v6inv4asv6 = ~(options->v6inv4asv6);
689
++            break;
690
++        case 10:
691
+             maketimermenu(&timermenu);
692
+             trow = 1;
693
+             do {
694
+@@ -362,22 +371,22 @@ void setoptions(struct OPTIONS *options,
695
+             update_panels();
696
+             doupdate();
697
+             break;
698
+-        case 11:
699
++        case 12:
700
+             addmoreports(ports);
701
+             break;
702
+-        case 12:
703
++        case 13:
704
+             removeaport(ports);
705
+             break;
706
+-        case 14:
707
++        case 15:
708
+             ethdescmgr(LINK_ETHERNET);
709
+             break;
710
+-        case 15:
711
++        case 16:
712
+             ethdescmgr(LINK_FDDI);
713
+             break;
714
+         }
715
+ 
716
+         indicatesetting(row, options, statwin);
717
+-    } while (row != 17);
718
++    } while (row != 18);
719
+ 
720
+     tx_destroymenu(&menu);
721
+     del_panel(statpanel);
722
+diff -up iptraf-3.0.1/src/options.h.ipv6 iptraf-3.0.1/src/options.h
723
+--- iptraf-3.0.1/src/options.h.ipv6	2005-09-13 08:42:54.000000000 +0200
724
+@@ -2,7 +2,7 @@
725
+ struct OPTIONS {
726
+     unsigned int color:1,
727
+         logging:1,
728
+-        revlook:1, servnames:1, promisc:1, actmode:1, mac:1, dummy:9;
729
++        revlook:1, servnames:1, promisc:1, actmode:1, mac:1, v6inv4asv6:1, dummy:8;
730
+     unsigned int timeout;
731
+     unsigned int logspan;
732
+     unsigned int updrate;
733
+diff -up iptraf-3.0.1/src/othptab.c.ipv6 iptraf-3.0.1/src/othptab.c
734
+--- iptraf-3.0.1/src/othptab.c.ipv6	2008-09-02 13:57:02.000000000 +0200
735
+@@ -23,6 +23,8 @@ details.
736
+ #include <netinet/if_tr.h>
737
+ #include <linux/netdevice.h>
738
+ #include <netinet/if_fddi.h>
739
++#include <netinet/ip6.h>
740
++#include <netinet/icmp6.h>
741
+ #include <winops.h>
742
+ #include "arphdr.h"
743
+ #include "options.h"
744
+@@ -82,16 +84,12 @@ void process_dest_unreach(struct tcptabl
745
+                           char *ifname, int *nomem)
746
+ {
747
+     struct iphdr *ip;
748
++    struct ip6_hdr *ip6;
749
+     struct tcphdr *tcp;
750
+     struct tcptableent *tcpentry;
751
+ 
752
+     ip = (struct iphdr *) (packet + 8);
753
+ 
754
+-    if (ip->protocol != IPPROTO_TCP)
755
+-        return;
756
+-
757
+-    tcp = (struct tcphdr *) (packet + 8 + (ip->ihl * 4));
758
+-
759
+     /* 
760
+      * We really won't be making use of nomem here.  Timeout checking
761
+      * won't be performed either, so we just pass NULL as the pointer
762
+@@ -99,9 +97,23 @@ void process_dest_unreach(struct tcptabl
763
+      * and set its internal timeout variable to 0.
764
+      */
765
+ 
766
+-    tcpentry = in_table(table, ip->saddr, ip->daddr,
767
++    if (ip->version == 6)
768
++    {
769
++       ip6 = (struct ip6_hdr *) (packet + 8);
770
++       if (ip6->ip6_nxt != IPPROTO_TCP)
771
++           return;
772
++       tcp = (struct tcphdr *) (packet + 48);
773
++       tcpentry = in_table(table, 0, 0, ip6->ip6_src.s6_addr, ip6->ip6_dst.s6_addr,
774
+                         ntohs(tcp->source), ntohs(tcp->dest), ifname,
775
+                         0, NULL, nomem, NULL);
776
++    } else {
777
++        if (ip->protocol != IPPROTO_TCP)
778
++            return;
779
++        tcp = (struct tcphdr *) (packet + 8 + (ip->ihl * 4));
780
++        tcpentry = in_table(table, ip->saddr, ip->daddr, NULL, NULL,
781
++                        ntohs(tcp->source), ntohs(tcp->dest), ifname,
782
++                        0, NULL, nomem, NULL);
783
++    }
784
+ 
785
+     if (tcpentry != NULL) {
786
+         tcpentry->stat = tcpentry->oth_connection->stat = FLAG_RST;
787
+@@ -112,6 +124,7 @@ void process_dest_unreach(struct tcptabl
788
+ struct othptabent *add_othp_entry(struct othptable *table,
789
+                                   struct tcptable *tcptab,
790
+                                   unsigned long saddr, unsigned long daddr,
791
++				  struct in6_addr *s6addr, struct in6_addr *d6addr,
792
+                                   int is_ip, int protocol,
793
+                                   unsigned short linkproto, char *packet,
794
+                                   char *packet2, unsigned int br,
795
+@@ -158,10 +171,18 @@ struct othptabent *add_othp_entry(struct
796
+     if (is_ip) {
797
+         new_entry->saddr = isaddr.s_addr = saddr;
798
+         new_entry->daddr = idaddr.s_addr = daddr;
799
+-
800
+-        revname(rev_lookup, &isaddr, new_entry->s_fqdn, rvnfd);
801
+-        revname(rev_lookup, &idaddr, new_entry->d_fqdn, rvnfd);
802
+-
803
++        if (s6addr != NULL)
804
++            memcpy(&new_entry->s6addr, s6addr, 16);
805
++        else
806
++            memset(&new_entry->s6addr, 0, 16);
807
++
808
++        if (d6addr != NULL)
809
++            memcpy(&new_entry->d6addr, d6addr, 16);
810
++        else
811
++            memset(&new_entry->s6addr, 0, 16);
812
++ 
813
++        revname(rev_lookup, &isaddr, s6addr, new_entry->s_fqdn, rvnfd);
814
++        revname(rev_lookup, &idaddr, d6addr, new_entry->d_fqdn, rvnfd);
815
+         if (!fragment) {
816
+             if (protocol == IPPROTO_ICMP) {
817
+                 new_entry->un.icmp.type =
818
+@@ -420,6 +441,14 @@ void printothpentry(struct othptable *ta
819
+         wattrset(table->othpwin, GREATTR);
820
+         strcpy(protname, "GRE");
821
+         break;
822
++     case IPPROTO_ICMPV6:
823
++        wattrset(table->othpwin, ICMPV6ATTR);
824
++        strcpy(protname, "ICMPv6");
825
++        break;
826
++     case IPPROTO_IPV6:
827
++        wattrset(table->othpwin, IPV6ATTR);
828
++        strcpy(protname, "IPv6 tun");
829
++        break;
830
+     default:
831
+         wattrset(table->othpwin, UNKNIPATTR);
832
+         protptr = getprotobynumber(entry->protocol);
833
+@@ -525,7 +554,71 @@ void printothpentry(struct othptable *ta
834
+                 strcpy(description, "bad/unkn");
835
+                 break;
836
+             }
837
+-
838
++        } else if (entry->protocol == IPPROTO_ICMPV6) {
839
++            switch (entry->un.icmp6.type) {
840
++            case ICMP6_DST_UNREACH:
841
++                strcpy(description, "dest unrch");
842
++                switch (entry->un.icmp6.code) {
843
++                case ICMP6_DST_UNREACH_NOROUTE:
844
++                    strcpy(additional, "no route");
845
++                    break;
846
++                case ICMP6_DST_UNREACH_ADMIN:
847
++                    strcpy(additional, "admin");
848
++                    break;
849
++                case ICMP6_DST_UNREACH_NOTNEIGHBOR:
850
++                    strcpy(additional, "not neigh");
851
++                    break;
852
++                case ICMP6_DST_UNREACH_ADDR:
853
++                    strcpy(additional, "unreach addr");
854
++                    break;
855
++                case ICMP6_DST_UNREACH_NOPORT:
856
++                    strcpy(additional, "no port");
857
++                    break;
858
++                }
859
++                break;
860
++    	    case ICMP6_PACKET_TOO_BIG:
861
++            	strcpy(description, "pkt too big");
862
++                break;
863
++	    case ICMP6_TIME_EXCEEDED:
864
++    	        strcpy(description, "time exceeded");
865
++    		break;
866
++            case ICMP6_PARAM_PROB:
867
++	        strcpy(description, "param prob");
868
++    	        break;
869
++            case ICMP6_ECHO_REQUEST:
870
++                strcpy(description, "echo req");
871
++                break;
872
++            case ICMP6_ECHO_REPLY:
873
++                strcpy(description, "echo rply");
874
++                break;
875
++            case ND_ROUTER_SOLICIT:
876
++                strcpy(description, "router sol");
877
++                break;
878
++            case ND_ROUTER_ADVERT:
879
++                strcpy(description, "router adv");
880
++                break;
881
++            case ICMP6_MEMBERSHIP_QUERY:
882
++                strcpy(description, "mbrship query");
883
++                break;
884
++            case ICMP6_MEMBERSHIP_REPORT:
885
++                strcpy(description, "mbrship report");
886
++                break;
887
++            case ICMP6_MEMBERSHIP_REDUCTION:
888
++                strcpy(description, "mbrship reduc");
889
++                break;
890
++            case ND_NEIGHBOR_SOLICIT:
891
++                strcpy(description, "neigh sol");
892
++                break;
893
++            case ND_NEIGHBOR_ADVERT:
894
++                strcpy(description, "neigh adv");
895
++                break;
896
++            case ND_REDIRECT:
897
++                strcpy(description, "redirect");
898
++                break;
899
++            default:
900
++                strcpy(description, "bad/unkn");
901
++        	break;
902
++            }
903
+         } else if (entry->protocol == IPPROTO_OSPFIGP) {
904
+             switch (entry->un.ospf.type) {
905
+             case OSPF_TYPE_HELLO:
906
+@@ -569,11 +662,11 @@ void printothpentry(struct othptable *ta
907
+     strcat(msgstring, scratchpad);
908
+ 
909
+     if ((entry->protocol == IPPROTO_UDP) && (!(entry->fragment))) {
910
+-        sprintf(scratchpad, "from %.25s:%s to %.25s:%s",
911
++        sprintf(scratchpad, "from %.40s:%s to %.40s:%s",
912
+                 entry->s_fqdn, entry->un.udp.s_sname,
913
+                 entry->d_fqdn, entry->un.udp.d_sname);
914
+     } else {
915
+-        sprintf(scratchpad, "from %.25s to %.25s", entry->s_fqdn,
916
++        sprintf(scratchpad, "from %.40s to %.40s", entry->s_fqdn,
917
+                 entry->d_fqdn);
918
+     }
919
+ 
920
+diff -up iptraf-3.0.1/src/othptab.h.ipv6 iptraf-3.0.1/src/othptab.h
921
+--- iptraf-3.0.1/src/othptab.h.ipv6	2005-09-13 08:42:54.000000000 +0200
922
+@@ -34,6 +34,8 @@ Copyright (c) Gerard Paul Java 1997
923
+ struct othptabent {
924
+     unsigned long int saddr;
925
+     unsigned long int daddr;
926
++    struct in6_addr s6addr;
927
++    struct in6_addr d6addr;
928
+     char smacaddr[15];
929
+     char dmacaddr[15];
930
+     unsigned short linkproto;
931
+@@ -69,6 +71,10 @@ struct othptabent {
932
+             char src_mac_address[6];
933
+             char dest_mac_address[6];
934
+         } rarp;
935
++        struct {
936
++            uint8_t     type;
937
++            uint8_t     code;
938
++        } icmp6;	
939
+     } un;
940
+     unsigned int type;
941
+     unsigned int code;
942
+@@ -133,9 +139,9 @@ void process_dest_unreach(struct tcptabl
943
+ struct othptabent *add_othp_entry(struct othptable *table,
944
+                                   struct tcptable *tcptab,
945
+                                   unsigned long saddr,
946
+-                                  unsigned long daddr, int is_ip,
947
+-                                  int protocol, unsigned short linkproto,
948
+-                                  char *packet, char *netpacket,
949
++                                  unsigned long daddr, struct in6_addr *s6addr,
950
++				  struct in6_addr *d6addr, int is_ip, int protocol, 
951
++				  unsigned short linkproto, char *packet, char *netpacket,
952
+                                   unsigned int br, char *ifname,
953
+                                   int *rev_lookup, int rvnamedon,
954
+                                   unsigned int tm, int logging,
955
+diff -up iptraf-3.0.1/src/packet.c.ipv6 iptraf-3.0.1/src/packet.c
956
+--- iptraf-3.0.1/src/packet.c.ipv6	2007-09-25 11:21:18.000000000 +0200
957
+@@ -28,6 +28,7 @@ details.
958
+ #include <sys/socket.h>
959
+ #include <netinet/in.h>
960
+ #include <netinet/ip.h>
961
++#include <netinet/ip6.h>
962
+ #include <netinet/tcp.h>
963
+ #include <sys/time.h>
964
+ #include <net/if_arp.h>
965
+@@ -303,6 +304,7 @@ int processpacket(char *tpacket, char **
966
+ {
967
+     static char aligned_buf[ALIGNED_BUF_LEN];
968
+     struct iphdr *ip;
969
++    struct ip6_hdr *ip6;
970
+     int hdr_check;
971
+     register int ip_checksum;
972
+     register int iphlen;
973
+@@ -356,7 +358,7 @@ int processpacket(char *tpacket, char **
974
+      * Apply non-IP packet filter
975
+      */
976
+ 
977
+-    if (fromaddr->sll_protocol != ETH_P_IP) {
978
++    if ((fromaddr->sll_protocol != ETH_P_IP) && (fromaddr->sll_protocol != ETH_P_IPV6)) {
979
+         if ((fromaddr->sll_protocol == ETH_P_ARP) ||
980
+             (fromaddr->sll_protocol == ETH_P_RARP)) {
981
+             if (!nonipfilter(filter, fromaddr->sll_protocol)) {
982
+@@ -370,9 +372,7 @@ int processpacket(char *tpacket, char **
983
+         return PACKET_OK;
984
+     }
985
+ 
986
+-    /*
987
+-     * TODO: Insert IPv6 processing code here
988
+-     */
989
++    if (fromaddr->sll_protocol == ETH_P_IP) {
990
+ 
991
+     /*
992
+      * At this point, we're now processing IP packets.  Start by getting
993
+@@ -389,7 +389,7 @@ int processpacket(char *tpacket, char **
994
+     ip->check = 0;
995
+     hdr_check = in_cksum((u_short *) ip, iphlen);
996
+ 
997
+-    if (hdr_check != ip_checksum)
998
++    if ((hdr_check != ip_checksum))
999
+         return CHECKSUM_ERROR;
1000
+ 
1001
+     if ((ip->protocol == IPPROTO_TCP || ip->protocol == IPPROTO_UDP) &&
1002
+@@ -453,9 +453,28 @@ int processpacket(char *tpacket, char **
1003
+                                            ip->protocol, match_opposite,
1004
+                                            &(filter->fl))))
1005
+             return PACKET_FILTERED;
1006
+-    }
1007
+-
1008
+-    return PACKET_OK;
1009
++      }
1010
++      return PACKET_OK;
1011
++     }
1012
++     else if (fromaddr->sll_protocol == ETH_P_IPV6) {
1013
++       ip6 = (struct ip6_hdr *) (*packet);
1014
++       iphlen = 40;
1015
++       //TODO: Filter packets
1016
++       if (ip6->ip6_nxt == IPPROTO_TCP) {
1017
++           in_ip.tcp = (struct tcphdr *) ((char *) ip6 + iphlen);
1018
++           if (sport != NULL)
1019
++               *sport = in_ip.tcp->source;
1020
++           if (dport != NULL)
1021
++               *dport = in_ip.tcp->dest;
1022
++       } else if (ip6->ip6_nxt == IPPROTO_UDP) {
1023
++           in_ip.udp = (struct udphdr *) ((char *) ip6 + iphlen);
1024
++           if (sport != NULL)
1025
++               *sport = in_ip.udp->source;
1026
++           if (dport != NULL)
1027
++               *dport = in_ip.udp->dest;
1028
++       }
1029
++     }
1030
++     return PACKET_OK;
1031
+ }
1032
+ 
1033
+ void pkt_cleanup(void)
1034
+diff -up iptraf-3.0.1/src/revname.c.ipv6 iptraf-3.0.1/src/revname.c
1035
+--- iptraf-3.0.1/src/revname.c.ipv6	2005-09-13 08:42:54.000000000 +0200
1036
+@@ -153,7 +153,7 @@ void close_rvn_socket(int fd)
1037
+     }
1038
+ }
1039
+ 
1040
+-int revname(int *lookup, struct in_addr *saddr, char *target, int rvnfd)
1041
++int revname(int *lookup, struct in_addr *saddr, struct in6_addr *s6addr, char *target, int rvnfd)
1042
+ {
1043
+     struct hostent *he;
1044
+     struct rvn rpkt;
1045
+@@ -173,6 +173,11 @@ int revname(int *lookup, struct in_addr 
1046
+             rpkt.type = RVN_REQUEST;
1047
+             rpkt.saddr.s_addr = saddr->s_addr;
1048
+ 
1049
++           if (s6addr != NULL)
1050
++               memcpy(rpkt.s6addr.s6_addr, s6addr->s6_addr, 16);
1051
++           else
1052
++               memset(rpkt.s6addr.s6_addr, 0, 4);
1053
++
1054
+             sendto(rvnfd, &rpkt, sizeof(struct rvn), 0,
1055
+                    (struct sockaddr *) &su,
1056
+                    sizeof(su.sun_family) + strlen(su.sun_path));
1057
+@@ -197,7 +202,10 @@ int revname(int *lookup, struct in_addr 
1058
+             } while ((br < 0) && (errno == EINTR));
1059
+ 
1060
+             if (br < 0) {
1061
++                if (saddr->s_addr != 0)
1062
+                 strcpy(target, inet_ntoa(*saddr));
1063
++                else
1064
++                    inet_ntop(AF_INET6, s6addr, target, 44);
1065
+                 printipcerr();
1066
+                 *lookup = 0;
1067
+                 return RESOLVED;
1068
+@@ -205,18 +213,26 @@ int revname(int *lookup, struct in_addr 
1069
+             strncpy(target, rpkt.fqdn, 44);
1070
+             return (rpkt.ready);
1071
+         } else {
1072
+-            he = gethostbyaddr((char *) saddr,
1073
+-                               sizeof(struct in_addr), AF_INET);
1074
++           if (saddr->s_addr != 0)
1075
++               he = gethostbyaddr((char *) saddr, sizeof(struct in_addr), AF_INET);
1076
++           else
1077
++               he = gethostbyaddr((char *) s6addr, sizeof(struct in6_addr), AF_INET6);
1078
+ 
1079
+-            if (he == NULL)
1080
++            if (he == NULL) {
1081
++                if (saddr->s_addr != 0)
1082
+                 strcpy(target, inet_ntoa(*saddr));
1083
+             else
1084
++                inet_ntop(AF_INET6, s6addr, target, 44);
1085
++            } else {
1086
+                 strncpy(target, he->h_name, 44);
1087
++            }
1088
+ 
1089
+             return RESOLVED;
1090
+         }
1091
+     } else {
1092
+-        strcpy(target, inet_ntoa(*saddr));
1093
+-        return RESOLVED;
1094
++        if (saddr->s_addr != 0 || s6addr == NULL)
1095
++            strcpy(target, inet_ntoa(*saddr));
1096
++        else
1097
++            inet_ntop(AF_INET6, s6addr, target, 44);
1098
+     }
1099
+ }
1100
+diff -up iptraf-3.0.1/src/revname.h.ipv6 iptraf-3.0.1/src/revname.h
1101
+--- iptraf-3.0.1/src/revname.h.ipv6	2005-09-13 08:42:54.000000000 +0200
1102
+@@ -8,4 +8,5 @@ int rvnamedactive();
1103
+ int killrvnamed();
1104
+ void open_rvn_socket(int *fd);
1105
+ void close_rvn_socket(int fd);
1106
+-int revname(int *lookup, struct in_addr *saddr, char *target, int rvnfd);
1107
++
1108
++int revname(int *lookup, struct in_addr *saddr, struct in6_addr *s6addr, char *target, int rvnfd);
1109
+diff -up iptraf-3.0.1/src/rvnamed.c.ipv6 iptraf-3.0.1/src/rvnamed.c
1110
+--- iptraf-3.0.1/src/rvnamed.c.ipv6	2005-09-13 08:42:54.000000000 +0200
1111
+@@ -55,6 +55,7 @@ details.
1112
+ 
1113
+ struct hosts {
1114
+     unsigned long addr;
1115
++    uint8_t addr6[16];
1116
+     char fqdn[45];
1117
+     int ready;
1118
+ };
1119
+@@ -93,12 +94,17 @@ void process_rvn_packet(struct rvn *rvnp
1120
+ 
1121
+     ccfd = socket(PF_UNIX, SOCK_DGRAM, 0);
1122
+ 
1123
+-    he = gethostbyaddr((char *) &(rvnpacket->saddr),
1124
+-                       sizeof(struct in_addr), AF_INET);
1125
++    if (rvnpacket->saddr.s_addr != 0)
1126
++       he = gethostbyaddr((char *) &(rvnpacket->saddr), sizeof(struct in_addr), AF_INET);
1127
++    else
1128
++       he = gethostbyaddr((char *) &(rvnpacket->s6addr), sizeof(struct in6_addr), AF_INET6);
1129
+ 
1130
+-    if (he == NULL)
1131
++    if (he == NULL) {
1132
++      if (rvnpacket->saddr.s_addr != 0)
1133
+         strcpy(rvnpacket->fqdn, inet_ntoa(rvnpacket->saddr));
1134
+-    else {
1135
++      else
1136
++           inet_ntop(AF_INET6, &(rvnpacket->s6addr), rvnpacket->fqdn, sizeof(rvnpacket->fqdn));
1137
++    } else {
1138
+         bzero(rvnpacket->fqdn, 45);
1139
+         strncpy(rvnpacket->fqdn, he->h_name, 44);
1140
+     }
1141
+@@ -122,10 +128,14 @@ int name_resolved(struct rvn *rvnpacket,
1142
+     unsigned int i = 0;
1143
+ 
1144
+     while (i != lastfree) {
1145
++        if (rvnpacket->saddr.s_addr != 0) {
1146
+         if ((rvnpacket->saddr.s_addr == hostlist[i].addr)
1147
+             && (hostlist[i].ready == RESOLVED))
1148
+             return i;
1149
+-
1150
++        } else {
1151
++            if (!memcmp(rvnpacket->s6addr.s6_addr, hostlist[i].addr6, sizeof(hostlist[i].addr6)))
1152
++            return i;
1153
++        }
1154
+         i++;
1155
+     }
1156
+ 
1157
+@@ -300,7 +310,8 @@ int main(void)
1158
+                 hi = 0;
1159
+ 
1160
+                 while (hi <= lastfree) {
1161
+-                    if (hostlist[hi].addr == rvnpacket.saddr.s_addr)
1162
++                    if ((hostlist[hi].addr == rvnpacket.saddr.s_addr) &&
1163
++                        !memcmp(rvnpacket.s6addr.s6_addr, hostlist[hi].addr6, sizeof(hostlist[hi].addr6)))
1164
+                         break;
1165
+                     hi++;
1166
+                 }
1167
+@@ -313,6 +324,7 @@ int main(void)
1168
+                         hostindex = 0;
1169
+ 
1170
+                     hostlist[hi].addr = rvnpacket.saddr.s_addr;
1171
++                    memcpy(hostlist[hi].addr6, rvnpacket.s6addr.s6_addr, sizeof(hostlist[hi].addr6));
1172
+                 }
1173
+                 strncpy(hostlist[hi].fqdn, rvnpacket.fqdn, 44);
1174
+ 
1175
+@@ -400,6 +412,8 @@ int main(void)
1176
+                                  */
1177
+                                 hostlist[hostindex].addr =
1178
+                                     rvnpacket.saddr.s_addr;
1179
++                                memcpy(hostlist[hostindex].addr6, rvnpacket.s6addr.s6_addr,
1180
++                                        sizeof(hostlist[hostindex].addr6));
1181
+                                 hostlist[hostindex].ready = RESOLVING;
1182
+ 
1183
+                                 maxlogged = 0;
1184
+@@ -455,7 +469,10 @@ int main(void)
1185
+                         }
1186
+                         rvnpacket.type = RVN_REPLY;
1187
+                         bzero(rvnpacket.fqdn, 45);
1188
++                        if (rvnpacket.saddr.s_addr != 0)
1189
+                         strcpy(rvnpacket.fqdn, inet_ntoa(rvnpacket.saddr));
1190
++                        else
1191
++                            inet_ntop(AF_INET6, &rvnpacket.s6addr, rvnpacket.fqdn, sizeof(rvnpacket.fqdn));
1192
+                         rvnpacket.ready = RESOLVING;
1193
+ 
1194
+                         br = sendto(ifd, &rvnpacket, sizeof(struct rvn), 0,
1195
+diff -up iptraf-3.0.1/src/rvnamed.h.ipv6 iptraf-3.0.1/src/rvnamed.h
1196
+--- iptraf-3.0.1/src/rvnamed.h.ipv6	2005-09-13 08:42:54.000000000 +0200
1197
+@@ -22,5 +22,6 @@ struct rvn {
1198
+     int type;
1199
+     int ready;
1200
+     struct in_addr saddr;
1201
++    struct in6_addr s6addr;
1202
+     char fqdn[45];
1203
+ };
1204
+diff -up iptraf-3.0.1/src/serv.c.ipv6 iptraf-3.0.1/src/serv.c
1205
+--- iptraf-3.0.1/src/serv.c.ipv6	2005-09-13 08:42:54.000000000 +0200
1206
+@@ -31,6 +31,7 @@ details.
1207
+ #include <sys/socket.h>
1208
+ #include <netinet/in.h>
1209
+ #include <netinet/ip.h>
1210
++#include <netinet/ip6.h>
1211
+ #include <netinet/udp.h>
1212
+ #include <linux/if_packet.h>
1213
+ #include <linux/if_ether.h>
1214
+@@ -1032,6 +1033,8 @@ void servmon(char *ifname, struct portta
1215
+             if (pkt_result != PACKET_OK)
1216
+                 continue;
1217
+ 
1218
++	    if (fromaddr.sll_protocol == ETH_P_IP) {
1219
++
1220
+             if ((((struct iphdr *) ipacket)->protocol == IPPROTO_TCP)
1221
+                 || (((struct iphdr *) ipacket)->protocol == IPPROTO_UDP)) {
1222
+                 updateportent(&list, ((struct iphdr *) ipacket)->protocol,
1223
+@@ -1049,6 +1052,26 @@ void servmon(char *ifname, struct portta
1224
+                 }
1225
+             }
1226
+         }
1227
++        } else {
1228
++            if ((((struct ip6_hdr *) ipacket)->ip6_nxt == IPPROTO_TCP)
1229
++                || (((struct ip6_hdr *) ipacket)->ip6_nxt ==
1230
++                    IPPROTO_UDP)) {
1231
++                updateportent(&list, ((struct ip6_hdr *) ipacket)->ip6_nxt,
1232
++                    ntohs(sport),
1233
++                    ntohs(((struct ip6_hdr *) ipacket)->ip6_plen + 40),
1234
++                    idx, 0, ports, options->servnames);
1235
++                updateportent(&list, ((struct ip6_hdr *) ipacket)->ip6_nxt,
1236
++                    ntohs(dport),
1237
++                    ntohs(((struct ip6_hdr *) ipacket)->ip6_plen + 40),
1238
++                    idx, 1, ports, options->servnames);
1239
++                if ((list.barptr == NULL) && (list.head != NULL)) {
1240
++                    set_barptr((char **) &(list.barptr), (char *) list.head,
1241
++                        &(list.head->starttime), (char *) &(list.head->spans),
1242
++                        sizeof(struct serv_spans), statwin, &statcleared, statx);
1243
++                    list.baridx = 1;
1244
++                }
1245
++            }
1246
++        }
1247
+     }
1248
+ 
1249
+     if (logging) {
1250
+diff -up iptraf-3.0.1/src/tcptable.c.ipv6 iptraf-3.0.1/src/tcptable.c
1251
+--- iptraf-3.0.1/src/tcptable.c.ipv6	2005-09-13 08:42:54.000000000 +0200
1252
+@@ -59,8 +59,8 @@ void setlabels(WINDOW * win, int mode)
1253
+  * The hash function for the TCP hash table
1254
+  */
1255
+ 
1256
+-unsigned int tcp_hash(unsigned long saddr, unsigned int sport,
1257
+-                      unsigned long daddr, unsigned int dport,
1258
++unsigned int tcp_hash(unsigned long saddr, uint32_t *s6addr, unsigned int sport,
1259
++                      unsigned long daddr, uint32_t *d6addr, unsigned int dport,
1260
+                       char *ifname)
1261
+ {
1262
+     int i;
1263
+@@ -69,6 +69,13 @@ unsigned int tcp_hash(unsigned long sadd
1264
+     for (i = 0; i <= strlen(ifname) - 1; i++)
1265
+         ifsum += ifname[i];
1266
+ 
1267
++    if (s6addr != 0 && d6addr != 0) {
1268
++       for (i = 0; i < 4; i++) {
1269
++               saddr ^= s6addr[i];
1270
++               daddr ^= d6addr[i];
1271
++       }
1272
++    }
1273
++
1274
+     return ((ifsum + (4 * saddr) + (3 * sport) +
1275
+              (2 * daddr) + dport) % ENTRIES_IN_HASH_TABLE);
1276
+ }
1277
+@@ -139,8 +146,8 @@ int add_tcp_hash_entry(struct tcptable *
1278
+     unsigned int hp;            /* hash position in table */
1279
+     struct tcp_hashentry *ptmp;
1280
+ 
1281
+-    hp = tcp_hash(entry->saddr.s_addr, entry->sport,
1282
+-                  entry->daddr.s_addr, entry->dport, entry->ifname);
1283
++    hp = tcp_hash(entry->saddr.s_addr, entry->s6addr.s6_addr32, entry->sport,
1284
++                  entry->daddr.s_addr, entry->d6addr.s6_addr32, entry->dport, entry->ifname);
1285
+ 
1286
+     ptmp = malloc(sizeof(struct tcp_hashentry));
1287
+     bzero(ptmp, sizeof(struct tcp_hashentry));
1288
+@@ -215,6 +222,8 @@ void del_tcp_hash_node(struct tcptable *
1289
+ struct tcptableent *addentry(struct tcptable *table,
1290
+                              unsigned long int saddr,
1291
+                              unsigned long int daddr,
1292
++                             uint8_t *s6addr,
1293
++                             uint8_t *d6addr,
1294
+                              unsigned int sport, unsigned int dport,
1295
+                              int protocol,
1296
+                              char *ifname, int *rev_lookup,
1297
+@@ -311,8 +320,22 @@ struct tcptableent *addentry(struct tcpt
1298
+ 
1299
+     new_entry->saddr.s_addr = new_entry->oth_connection->daddr.s_addr =
1300
+         saddr;
1301
++    if (s6addr == NULL) {
1302
++        memset(&new_entry->s6addr, 0, 16);
1303
++	memset(&new_entry->oth_connection->d6addr, 0, 16);
1304
++    } else {
1305
++        memcpy(&new_entry->s6addr, s6addr, 16);
1306
++        memcpy(&new_entry->oth_connection->d6addr, s6addr, 16);
1307
++    }
1308
+     new_entry->daddr.s_addr = new_entry->oth_connection->saddr.s_addr =
1309
+         daddr;
1310
++    if (d6addr == NULL) {
1311
++       memset(&new_entry->d6addr, 0, 16);
1312
++       memset(&new_entry->oth_connection->s6addr, 0, 16);
1313
++    } else {
1314
++       memcpy(&new_entry->d6addr, d6addr, 16);
1315
++       memcpy(&new_entry->oth_connection->s6addr, d6addr, 16);
1316
++    }
1317
+     new_entry->protocol = protocol;
1318
+ 
1319
+     /*
1320
+@@ -349,9 +372,10 @@ struct tcptableent *addentry(struct tcpt
1321
+ 
1322
+     new_entry->stat = new_entry->oth_connection->stat = 0;
1323
+ 
1324
+-    new_entry->s_fstat = revname(rev_lookup, &(new_entry->saddr),
1325
++    new_entry->s_fstat = revname(rev_lookup, &(new_entry->saddr), &new_entry->s6addr,
1326
+                                  new_entry->s_fqdn, rvnfd);
1327
+-    new_entry->d_fstat = revname(rev_lookup, &(new_entry->daddr),
1328
++
1329
++    new_entry->d_fstat = revname(rev_lookup, &(new_entry->daddr), &new_entry->d6addr,
1330
+                                  new_entry->d_fqdn, rvnfd);
1331
+ 
1332
+     /*
1333
+@@ -490,7 +514,8 @@ void write_timeout_log(int logging, FILE
1334
+ }
1335
+ 
1336
+ struct tcptableent *in_table(struct tcptable *table, unsigned long saddr,
1337
+-                             unsigned long daddr, unsigned int sport,
1338
++                             unsigned long daddr, uint8_t *s6addr,
1339
++                             uint8_t *d6addr, unsigned int sport,
1340
+                              unsigned int dport, char *ifname,
1341
+                              int logging, FILE * logfile,
1342
+                              int *nomem, struct OPTIONS *opts)
1343
+@@ -503,6 +528,9 @@ struct tcptableent *in_table(struct tcpt
1344
+     time_t now;
1345
+     time_t timeout;
1346
+ 
1347
++    int sfree = 0;
1348
++    int dfree = 0;
1349
++
1350
+     if (opts != NULL)
1351
+         timeout = opts->timeout;
1352
+     else
1353
+@@ -515,12 +543,24 @@ struct tcptableent *in_table(struct tcpt
1354
+      * Determine hash table index for this set of addresses and ports
1355
+      */
1356
+ 
1357
+-    hp = tcp_hash(saddr, sport, daddr, dport, ifname);
1358
++    hp = tcp_hash(saddr, (uint32_t*) s6addr, sport, daddr, (uint32_t*) d6addr, dport, ifname);
1359
+     hashptr = table->hash_table[hp];
1360
+ 
1361
++    if (s6addr == NULL) {
1362
++       s6addr = malloc(sizeof(struct in6_addr));
1363
++       memset(s6addr, 0, 16);
1364
++       sfree = 1;
1365
++    }
1366
++    if (d6addr == NULL) {
1367
++       d6addr = malloc(sizeof(struct in6_addr));
1368
++       memset(d6addr, 0, 16);
1369
++       dfree = 1;
1370
++    }
1371
+     while (hashptr != NULL) {
1372
+         if ((hashptr->tcpnode->saddr.s_addr == saddr) &&
1373
++            (!memcmp(&hashptr->tcpnode->s6addr.s6_addr, s6addr, 16)) &&
1374
+             (hashptr->tcpnode->daddr.s_addr == daddr) &&
1375
++            (!memcmp(&hashptr->tcpnode->d6addr.s6_addr, d6addr, 16)) &&
1376
+             (hashptr->tcpnode->sport == sport) &&
1377
+             (hashptr->tcpnode->dport == dport) &&
1378
+             (strcmp(hashptr->tcpnode->ifname, ifname) == 0))
1379
+@@ -549,6 +589,9 @@ struct tcptableent *in_table(struct tcpt
1380
+         hashptr = hashptr->next_entry;
1381
+     }
1382
+ 
1383
++    if (sfree) free(s6addr);
1384
++    if (dfree) free(d6addr);
1385
++
1386
+     if (hashptr != NULL) {      /* needed to avoid SIGSEGV */
1387
+         if ((((hashptr->tcpnode->finsent == 2) &&
1388
+               (hashptr->tcpnode->oth_connection->finsent == 2))) ||
1389
+@@ -579,13 +622,13 @@ void updateentry(struct tcptable *table,
1390
+     char newmacaddr[15];
1391
+ 
1392
+     if (tableentry->s_fstat != RESOLVED) {
1393
+-        tableentry->s_fstat = revname(revlook, &(tableentry->saddr),
1394
++        tableentry->s_fstat = revname(revlook, &(tableentry->saddr), &(tableentry->s6addr),
1395
+                                       tableentry->s_fqdn, rvnfd);
1396
+         strcpy(tableentry->oth_connection->d_fqdn, tableentry->s_fqdn);
1397
+         tableentry->oth_connection->d_fstat = tableentry->s_fstat;
1398
+     }
1399
+     if (tableentry->d_fstat != RESOLVED) {
1400
+-        tableentry->d_fstat = revname(revlook, &(tableentry->daddr),
1401
++       tableentry->d_fstat = revname(revlook, &(tableentry->daddr), &(tableentry->d6addr),
1402
+                                       tableentry->d_fqdn, rvnfd);
1403
+         strcpy(tableentry->oth_connection->s_fqdn, tableentry->d_fqdn);
1404
+         tableentry->oth_connection->s_fstat = tableentry->d_fstat;
1405
+diff -up iptraf-3.0.1/src/tcptable.h.ipv6 iptraf-3.0.1/src/tcptable.h
1406
+--- iptraf-3.0.1/src/tcptable.h.ipv6	2008-09-02 13:57:02.000000000 +0200
1407
+@@ -47,6 +47,8 @@
1408
+ struct tcptableent {
1409
+     struct in_addr saddr;
1410
+     struct in_addr daddr;
1411
++    struct in6_addr s6addr;
1412
++    struct in6_addr d6addr;
1413
+     char s_fqdn[45];            /* fully-qualified domain names */
1414
+     char d_fqdn[45];
1415
+     int s_fstat;
1416
+@@ -121,6 +123,7 @@ void init_tcp_table(struct tcptable *tab
1417
+ struct tcptableent *addentry(struct tcptable *table,
1418
+                              unsigned long int saddr,
1419
+                              unsigned long int daddr,
1420
++                             uint8_t *s6addr, uint8_t *d6addr,
1421
+                              unsigned int sport, unsigned int dport,
1422
+                              int protocol,
1423
+                              char *ifname, int *rev_lookup, int rvnamedon,
1424
+@@ -128,6 +131,7 @@ struct tcptableent *addentry(struct tcpt
1425
+ 
1426
+ struct tcptableent *in_table(struct tcptable *table,
1427
+                              unsigned long saddr, unsigned long daddr,
1428
++                             uint8_t *s6addr, uint8_t *d6addr,
1429
+                              unsigned int sport, unsigned int dport,
1430
+                              char *ifname,
1431
+                              int logging, FILE * logfile, int *nomem,
0 1432
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+diff -up iptraf-3.0.1/src/packet.c.old iptraf-3.0.1/src/packet.c
1
+--- iptraf-3.0.1/src/packet.c.old	2015-11-30 12:20:11.403710380 -0800
2
+@@ -36,7 +36,7 @@ details.
3
+ #include <linux/if_ether.h>
4
+ #include <linux/netdevice.h>
5
+ #include <linux/if_fddi.h>
6
+-#include <linux/if_tr.h>
7
++#include <netinet/if_tr.h>
8
+ #include <linux/isdn.h>
9
+ #include <linux/sockios.h>
10
+ #include <msgboxes.h>
11
+
12
+diff -up iptraf-3.0.1/src/hostmon.c.old iptraf-3.0.1/src/hostmon.c
13
+--- iptraf-3.0.1/src/hostmon.c.old	2015-11-30 12:42:19.445405357 -0800
14
+@@ -32,7 +32,7 @@ details.
15
+ #include <linux/if_ether.h>
16
+ #include <linux/netdevice.h>
17
+ #include <linux/if_fddi.h>
18
+-#include <linux/if_tr.h>
19
++#include <netinet/if_tr.h>
20
+ #include <net/if_arp.h>
21
+ #include <stdlib.h>
22
+ #include <time.h>
0 23
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+diff -up iptraf-3.0.1/src/serv.c.servmon-fix iptraf-3.0.1/src/serv.c
1
+--- iptraf-3.0.1/src/serv.c.servmon-fix	2009-12-28 14:37:25.000000000 +0100
2
+@@ -1052,7 +1052,6 @@ void servmon(char *ifname, struct portta
3
+                     list.baridx = 1;
4
+                 }
5
+             }
6
+-        }
7
+         } else {
8
+             if ((((struct ip6_hdr *) ipacket)->ip6_nxt == IPPROTO_TCP)
9
+                 || (((struct ip6_hdr *) ipacket)->ip6_nxt ==
10
+@@ -1073,6 +1072,7 @@ void servmon(char *ifname, struct portta
11
+                 }
12
+             }
13
+         }
14
++        }
15
+     }
16
+ 
17
+     if (logging) {
0 18
new file mode 100644
... ...
@@ -0,0 +1,77 @@
0
+Summary: IPTraf is a console-based network statistics utility
1
+Name:    iptraf
2
+Version: 3.0.1
3
+Release: 1%{?dist}
4
+License: GPLv2
5
+URL: ftp://iptraf.seul.org/pub/iptraf/%{name}-%{version}.tar.gz
6
+Source: %{name}-%{version}.tar.gz
7
+%define sha1 iptraf=9035b969868e49c276239d99964f427edfee87f3
8
+Patch0: iptraf-2.4.0-Makefile.patch
9
+Patch1: iptraf-2.7.0-install.patch
10
+Patch2: iptraf-2.7.0-doc.patch
11
+Patch4: iptraf-2.7.0-nostrip.patch
12
+Patch5: iptraf-3.0.0-setlocale.patch
13
+Patch6: iptraf-3.0.0-longdev.patch
14
+Patch7: iptraf-3.0.1-compile.fix.patch
15
+Patch8: iptraf-3.0.0-in_trafic.patch
16
+Patch9: iptraf-3.0.1-incltypes.patch
17
+Patch10: iptraf-3.0.0-ifname.patch
18
+Patch11: iptraf-3.0.0-interface.patch
19
+Patch12: iptraf-3.0.1-ipv6.patch
20
+Patch13: iptraf-3.0.1-ipv6-fix.patch
21
+Patch14: iptraf-3.0.1-servmon-fix.patch
22
+Patch15: 0001-fix-strcpy-overlap-memory.patch
23
+Patch16: iptraf-3.0.1-packet-fix.patch
24
+
25
+Group:      Applications/System
26
+Vendor:     VMware, Inc.
27
+Distribution:  Photon
28
+BuildRequires: ncurses-devel
29
+
30
+%description
31
+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.
32
+
33
+%prep
34
+%setup -q 
35
+%patch7 -p1 -b .compile
36
+%patch12 -p1 -b .ipv6
37
+%patch13 -p1 -b .ipv6-fix
38
+%patch14 -p1 -b .servmon-fix
39
+%patch15 -p1 -b .fix-strcpy-overlap-memory
40
+%patch0 -p1 -b .Makefile
41
+%patch1 -p1 -b .install
42
+%patch2 -p1 -b .doc
43
+%patch4 -p1 -b .nostrip
44
+%patch5 -p1 -b .setlocale
45
+%patch6 -p1 -b .longdev
46
+%patch8 -p1 -b .in_trafic
47
+%patch9 -p1 -b .incltypes
48
+%patch10 -p0 -b .ifname
49
+%patch11 -p1 -b .interface
50
+%patch16 -p1 -b .compile
51
+
52
+%build
53
+make -C src CFLAGS="-fno-strict-aliasing" \
54
+	TARGET=%{_bindir}
55
+
56
+%install
57
+rm -rf %{buildroot}
58
+install -d %{buildroot}/%{_bindir}
59
+install -d %{buildroot}/%{_mandir}/man8
60
+install -m644 Documentation/*.8 %{buildroot}/%{_mandir}/man8
61
+
62
+make -C src TARGET=%{buildroot}%{_bindir} \
63
+	install
64
+
65
+%clean
66
+rm -rf %{buildroot}
67
+
68
+%files
69
+%defattr(-,root,root,-)
70
+%{_mandir}/*/*
71
+%{_bindir}/*
72
+
73
+%changelog
74
+*   Mon Nov 30 2015 Xiaolin Li <xiaolinl@vmware.com> 3.0.1-1
75
+-   Initial build.  First version
76
+-   Patches from https://github.com/gooselinux/iptraf
0 77
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+Summary: C/C++ configuration file library
1
+Name:    libconfig
2
+Version: 1.5
3
+Release: 1%{?dist}
4
+License: LGPLv2
5
+URL: http://www.hyperrealm.com/libconfig/
6
+Source: %{name}-%{version}.tar.gz
7
+%define sha1 libconfig=24306c7efce07669a4053d0977a45e2f3a3add79
8
+Group:      Development/Tools
9
+Vendor:     VMware, Inc.
10
+Distribution:  Photon
11
+
12
+%description
13
+Libconfig is a simple library for processing structured configuration files, like this one: test.cfg. This file format is more compact and more readable than XML. And unlike XML, it is type-aware, so it is not necessary to do string parsing in application code.
14
+
15
+%prep
16
+%setup -q
17
+
18
+%build
19
+%configure --disable-static
20
+make %{?_smp_mflags}
21
+
22
+%install
23
+make DESTDIR=%{buildroot} install
24
+rm -rf %{buildroot}%{_libdir}/*.la
25
+rm -rf %{buildroot}%{_infodir}/dir
26
+
27
+%check
28
+./tests/libconfig_tests
29
+
30
+%post -p /sbin/ldconfig
31
+
32
+%postun -p /sbin/ldconfig
33
+
34
+%files
35
+%doc AUTHORS ChangeLog COPYING.LIB README
36
+%{_libdir}/libconfig*.so.*
37
+%{_includedir}/libconfig*
38
+%{_libdir}/libconfig*.so
39
+%{_libdir}/pkgconfig/libconfig*.pc
40
+%{_infodir}/libconfig.info*
41
+
42
+%changelog
43
+*	Tue Nov 24 2015 Xiaolin Li <xiaolinl@vmware.com> 0.7.2-1
44
+-   Initial build.  First version
0 45
new file mode 100644
... ...
@@ -0,0 +1,64 @@
0
+Summary: Intel LLDP Agent
1
+Name:    lldpad
2
+Version: 1.0.1
3
+Release: 2.git036e314%{?dist}
4
+License: GPLv2
5
+URL: http://open-lldp.org/
6
+Source: %{name}-%{version}.tar.gz
7
+%define sha1 lldpad=71e35298e926f0c03556cede4861dffa36928500
8
+Group:      System Environment/Daemons
9
+Vendor:     VMware, Inc.
10
+Distribution:  Photon
11
+
12
+BuildRequires: libconfig
13
+BuildRequires: libnl-devel
14
+BuildRequires: readline-devel
15
+
16
+%description
17
+The lldpad package comes with utilities to manage an LLDP interface with support for reading and configuring TLVs. TLVs and interfaces are individual controlled allowing flexible configuration for TX only, RX only, or TX/RX modes per TLV.
18
+
19
+%prep
20
+%setup -q -n open-lldp-036e314
21
+
22
+%build
23
+./bootstrap.sh
24
+%configure --disable-static
25
+make %{?_smp_mflags}
26
+
27
+%install
28
+make DESTDIR=%{buildroot} install 
29
+find %{buildroot} -name '*.la' -exec rm -f {} ';'
30
+mkdir -p %{buildroot}/lib/systemd/system
31
+mv %{buildroot}/%{_libdir}/systemd/system/lldpad.service \
32
+   	%{buildroot}/lib/systemd/system/lldpad.service
33
+mv %{buildroot}/%{_libdir}/systemd/system/lldpad.socket  \
34
+	%{buildroot}/lib/systemd/system/lldpad.socket
35
+install -vdm755 %{buildroot}/etc/systemd/system/multi-user.target.wants
36
+ln -sfv ../../../../lib/systemd/system/lldpad.socket \
37
+	%{buildroot}/etc/systemd/system/multi-user.target.wants/lldpad.socket
38
+
39
+
40
+%post
41
+/sbin/ldconfig
42
+
43
+%postun
44
+/sbin/ldconfig
45
+
46
+%files
47
+%{_sbindir}/*
48
+%{_libdir}/liblldp_clif.so.*
49
+%dir %{_sysconfdir}/bash_completion.d/
50
+%{_sysconfdir}/bash_completion.d/*
51
+%{_mandir}/man3/*
52
+%{_mandir}/man8/*
53
+%{_includedir}/*
54
+%{_libdir}/pkgconfig/*.pc
55
+%{_libdir}/liblldp_clif.so
56
+%{_sysconfdir}/systemd/system/multi-user.target.wants/lldpad.socket
57
+/lib/systemd/system/lldpad.service
58
+/lib/systemd/system/lldpad.socket
59
+
60
+
61
+%changelog
62
+*	Tue Nov 24 2015 Xiaolin Li <xiaolinl@vmware.com> 1.0.1-1
63
+-   Initial build.  First version
0 64
new file mode 100644
... ...
@@ -0,0 +1,33 @@
0
+Summary: Network traffic statics utility for Solaris and Linux
1
+Name:    nicstat
2
+Version: 1.95
3
+Release: 1%{?dist}
4
+License:	Artistic License 2.0
5
+URL:		http://sourceforge.net/projects/%{name}
6
+Source0:	http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
7
+%define sha1 nicstat=e6cfe836e674de9acd73bfd1ec82d28092ccf7cd
8
+Group:      Development/Tools
9
+Vendor:     VMware, Inc.
10
+Distribution:  Photon
11
+
12
+%description
13
+Nicstat is a Solaris and Linux command-line that prints out network statistics for all network interface cards (NICs), including packets, kilobytes per second, average packet sizes and more.
14
+
15
+%prep
16
+%setup -q
17
+
18
+%build
19
+gcc  -o3 -m64 %{name}.c -o %{name}
20
+
21
+%install
22
+install -p -m755 -D  %{name} %{buildroot}%{_bindir}/%{name}
23
+install -p -m644 -D  %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
24
+    
25
+
26
+%files
27
+%{_bindir}/*
28
+%{_mandir}/man1/*
29
+
30
+%changelog
31
+*	Mon Nov 30 2015 Xiaolin Li <xiaolinl@vmware.com> 1.95-1
32
+-   Initial build.  First version
0 33
\ No newline at end of file
... ...
@@ -86,6 +86,11 @@
86 86
         "lttng-tools",
87 87
         "userspace-rcu",
88 88
 	"mingetty",
89
-        "msr-tools"
89
+        "msr-tools",
90
+        "dstat",
91
+        "libconfig",
92
+        "iptraf",
93
+        "nicstat",
94
+        "lldpad"
90 95
             ]
91 96
 }