get_tr_ip_offset() is used only in one place (packet.c). Move
it there and make it static.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/Makefile.am | 2 --
src/packet.c | 31 +++++++++++++++++++++----------
src/tr.c | 39 ---------------------------------------
src/tr.h | 10 ----------
4 files changed, 21 insertions(+), 61 deletions(-)
delete mode 100644 src/tr.c
delete mode 100644 src/tr.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 63e516c..5dc7ccf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,7 +65,6 @@ LIB_H += externs.h
LIB_H += attrs.h
LIB_H += fltdefs.h
LIB_H += logvars.h
-LIB_H += tr.h
LIB_H += list.h
LIB_C += error.c
@@ -101,7 +100,6 @@ LIB_C += ifstats.c
LIB_C += deskman.c
LIB_C += hostmon.c
LIB_C += fltedit.c
-LIB_C += tr.c
LIB_C += cidr.c
iptraf_ng_SOURCES = \
diff --git a/src/packet.c b/src/packet.c
index f007b99..e253ff8 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -29,8 +29,6 @@ details.
#include "ifaces.h"
#include "packet.h"
#include "ipfrag.h"
-#include "tr.h"
-
/* Reimplement again
* Removed PPP, LINK_ISDN, PLIP
@@ -62,6 +60,24 @@ static int in_cksum(u_short * addr, int len)
return (u_short) (~sum);
}
+static unsigned int get_tr_ip_offset(char *pkt)
+{
+ struct trh_hdr *trh;
+ unsigned int riflen = 0;
+
+ trh = (struct trh_hdr *) pkt;
+
+ /*
+ * Check if this packet has TR routing information and get
+ * its length.
+ */
+ if (trh->saddr[0] & TR_RII)
+ riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
+
+ return sizeof(struct trh_hdr) - TR_MAXRIFLEN + riflen +
+ sizeof(struct trllc);
+}
+
static void adjustpacket(char *tpacket, struct sockaddr_ll *fromaddr,
char **packet, unsigned int *readlen)
{
@@ -101,14 +117,9 @@ static void adjustpacket(char *tpacket, struct sockaddr_ll
*fromaddr,
break;
case ARPHRD_IEEE802_TR:
case ARPHRD_IEEE802:
- /*
- * Token Ring patch supplied by Tomas Dvorak
- */
-
- /*
- * Get the start of the IP packet from the Token Ring frame.
- */
- dataoffset = get_tr_ip_offset((unsigned char *) tpacket);
+ /* Token Ring patch supplied by Tomas Dvorak */
+ /* Get the start of the IP packet from the Token Ring frame. */
+ dataoffset = get_tr_ip_offset(tpacket);
*packet = tpacket + dataoffset;
*readlen -= dataoffset;
break;
diff --git a/src/tr.c b/src/tr.c
deleted file mode 100644
index f8c186c..0000000
--- a/src/tr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (C) 2011 Nikola Pajkovsky (npajkovs(a)redhat.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-// TODO: full rewrite
-
-#include "iptraf-ng-compat.h"
-
-unsigned int get_tr_ip_offset(unsigned char *pkt)
-{
- struct trh_hdr *trh;
- unsigned int riflen = 0;
-
- trh = (struct trh_hdr *) pkt;
-
- /*
- * Check if this packet has TR routing information and get
- * its length.
- */
- if (trh->saddr[0] & TR_RII)
- riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
-
- return sizeof(struct trh_hdr) - TR_MAXRIFLEN + riflen +
- sizeof(struct trllc);
-}
diff --git a/src/tr.h b/src/tr.h
deleted file mode 100644
index 31fe5a6..0000000
--- a/src/tr.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef IPTRAF_NG_TR_H
-#define IPTRAF_NG_TR_H
-
-/*
- * tr.h - prototype for Token Ring header parser.
- */
-
-unsigned int get_tr_ip_offset(unsigned char *pkt);
-
-#endif /* IPTRAF_NG_TR_H */
--
1.7.8.4