[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch for vlan and vtun
Hi there,
This is a small "quick and dirty" :) patch allowing iptraf-2.7.0 to support
2 more interfaces:
1. "tunX" interface http://vtun.sourceforge.net/tun/index.html
2. "vlanXXXX" interface - IEEE 802.1Q
I send it also to Mr. Gerard P. Java.
If someone interested in testing it, I'll be grateful for any comments, bug
reports or suggestions.
Best Regards,
Strashinr Mihnev
--
diff -Nru iptraf-2.7.0/src/hostmon.c iptraf-2.7.1/src/hostmon.c
--- iptraf-2.7.0/src/hostmon.c Tue Apr 16 05:15:25 2002
+++ iptraf-2.7.1/src/hostmon.c Fri Mar 7 13:50:37 2003
@@ -701,7 +701,7 @@
int is_ip;
int ch;
- char ifname[8];
+ char ifname[10];
struct timeval tv;
unsigned long starttime;
@@ -855,7 +855,7 @@
linktype = getlinktype(fromaddr.sll_hatype, ifname, -1, NULL);
if ((linktype == LINK_ETHERNET) || (linktype == LINK_FDDI)
- || (linktype == LINK_PLIP) || (linktype == LINK_TR)) {
+ || (linktype == LINK_PLIP) || (linktype == LINK_TR) || (linktype ==
LINK_VLAN)) {
if (fromaddr.sll_protocol == htons(ETH_P_IP))
is_ip = 1;
else
@@ -865,7 +865,8 @@
* Check source address entry
*/
- if ((linktype == LINK_ETHERNET) || (linktype == LINK_PLIP)) {
+ if ((linktype == LINK_ETHERNET) || (linktype == LINK_PLIP)
+ || (linktype == LINK_VLAN)) {
memcpy(scratch_saddr,
((struct ethhdr *) buf)->h_source, ETH_ALEN);
memcpy(scratch_daddr, ((struct ethhdr *) buf)->h_dest,
diff -Nru iptraf-2.7.0/src/ifaces.c iptraf-2.7.1/src/ifaces.c
--- iptraf-2.7.0/src/ifaces.c Wed May 8 12:43:27 2002
+++ iptraf-2.7.1/src/ifaces.c Fri Mar 7 13:50:28 2003
@@ -32,14 +32,14 @@
#include "error.h"
extern int accept_unsupported_interfaces;
-#define NUM_SUPPORTED_IFACES 20
+#define NUM_SUPPORTED_IFACES 22
extern int daemonized;
char ifaces[][6] =
{ "lo", "eth", "sl", "ppp", "ippp", "plip", "fddi", "isdn", "dvb",
"pvc", "hdlc", "ipsec", "sbni", "tr", "wvlan", "wlan", "sm2", "sm3",
- "pent", "lec" };
+ "pent", "lec" , "tun" , "vlan" };
char *ltrim(char *buf)
{
diff -Nru iptraf-2.7.0/src/ifstats.c iptraf-2.7.1/src/ifstats.c
--- iptraf-2.7.0/src/ifstats.c Sat May 11 10:38:28 2002
+++ iptraf-2.7.1/src/ifstats.c Fri Mar 7 13:50:37 2003
@@ -130,7 +130,7 @@
{
FILE *fd;
char buf[161];
- char ifname[8];
+ char ifname[10];
struct iflist *itmp = NULL;
struct iflist *tail = NULL;
unsigned int index = 0;
@@ -757,7 +757,7 @@
unsigned int iphlen;
unsigned int sport, dport;
- char ifname[8];
+ char ifname[10];
struct sockaddr_ll fromaddr;
unsigned short linktype;
diff -Nru iptraf-2.7.0/src/ifstats.h iptraf-2.7.1/src/ifstats.h
--- iptraf-2.7.0/src/ifstats.h Tue May 7 05:45:57 2002
+++ iptraf-2.7.1/src/ifstats.h Fri Mar 7 13:50:37 2003
@@ -6,7 +6,7 @@
***/
struct iflist {
- char ifname[8];
+ char ifname[10];
unsigned int encap;
unsigned long long iptotal;
unsigned long badtotal;
diff -Nru iptraf-2.7.0/src/itrafmon.c iptraf-2.7.1/src/itrafmon.c
--- iptraf-2.7.0/src/itrafmon.c Wed May 8 04:42:30 2002
+++ iptraf-2.7.1/src/itrafmon.c Fri Mar 7 13:50:37 2003
@@ -591,7 +591,7 @@
int curwin = 0;
int readlen;
- char ifname[8];
+ char ifname[10];
unsigned long long total_pkts = 0;
diff -Nru iptraf-2.7.0/src/links.h iptraf-2.7.1/src/links.h
--- iptraf-2.7.0/src/links.h Tue Dec 18 04:45:16 2001
+++ iptraf-2.7.1/src/links.h Fri Mar 7 13:50:28 2003
@@ -9,5 +9,6 @@
#define LINK_FRAD 9
#define LINK_DLCI 10
#define LINK_TR 11
+#define LINK_VLAN 12
#define LINK_INVALID 0
diff -Nru iptraf-2.7.0/src/othptab.h iptraf-2.7.1/src/othptab.h
--- iptraf-2.7.0/src/othptab.h Thu Jun 7 13:28:27 2001
+++ iptraf-2.7.1/src/othptab.h Fri Mar 7 13:50:37 2003
@@ -42,7 +42,7 @@
int s_fstat;
int d_fstat;
unsigned int protocol;
- char iface[8];
+ char iface[10];
unsigned int pkt_length;
union {
diff -Nru iptraf-2.7.0/src/packet.c iptraf-2.7.1/src/packet.c
--- iptraf-2.7.0/src/packet.c Wed May 8 12:44:08 2002
+++ iptraf-2.7.1/src/packet.c Fri Mar 7 13:50:28 2003
@@ -98,6 +98,8 @@
result = LINK_ETHERNET;
else if (strncmp(ifname, "lec", 3) == 0)
result = LINK_ETHERNET;
+ else if (strncmp(ifname, "vlan", 4) == 0)
+ result = LINK_VLAN;
else if ((strncmp(ifname, "isdn", 4) == 0) && (isdn_fd != -1)) {
isdnent = isdn_table_lookup(isdnlist, ifname, isdn_fd);
@@ -178,6 +180,10 @@
case LINK_DLCI:
*packet = tpacket + 4;
*readlen -= 4;
+ break;
+ case LINK_VLAN:
+ *packet = tpacket + 18; // Maybe I should use here VLAN_ETH_HLEN instead
of 18
+ *readlen -= 18;
break;
case LINK_FDDI:
*packet = tpacket + sizeof(struct fddihdr);
diff -Nru iptraf-2.7.0/src/promisc.h iptraf-2.7.1/src/promisc.h
--- iptraf-2.7.0/src/promisc.h Wed Apr 5 10:15:15 2000
+++ iptraf-2.7.1/src/promisc.h Fri Mar 7 13:50:37 2003
@@ -9,7 +9,7 @@
*/
struct promisc_params {
- char ifname[8];
+ char ifname[10];
int saved_state;
int state_valid;
};
diff -Nru iptraf-2.7.0/src/serv.c iptraf-2.7.1/src/serv.c
--- iptraf-2.7.0/src/serv.c Sun May 19 14:25:02 2002
+++ iptraf-2.7.1/src/serv.c Fri Mar 7 13:50:37 2003
@@ -699,7 +699,7 @@
unsigned short linktype;
int br;
- char iface[8];
+ char iface[10];
unsigned int idx = 1;
unsigned int sport = 0;
diff -Nru iptraf-2.7.0/src/tcptable.h iptraf-2.7.1/src/tcptable.h
--- iptraf-2.7.0/src/tcptable.h Fri Dec 28 04:16:39 2001
+++ iptraf-2.7.1/src/tcptable.h Fri Mar 7 13:50:37 2003
@@ -64,7 +64,7 @@
unsigned long finack;
int partial;
int finsent;
- char ifname[8];
+ char ifname[10];
unsigned int index;
int reused;
int timedout;
diff -Nru iptraf-2.7.0/src/version iptraf-2.7.1/src/version
--- iptraf-2.7.0/src/version Wed May 15 09:51:40 2002
+++ iptraf-2.7.1/src/version Fri Mar 7 13:50:28 2003
@@ -1 +1 @@
-2.7.0
+2.7.1