Several arguments of this function are directly accessible from
struct pkt_hdr. Pass struct pkt_hdr pointer to updateentry() and
remove packet, linkproto and packetlength arguments.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/itrafmon.c | 16 +++++++---------
src/tcptable.c | 23 +++++++++--------------
src/tcptable.h | 10 +++++-----
3 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/src/itrafmon.c b/src/itrafmon.c
index b7afd25..d3e0d23 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -1056,17 +1056,15 @@ void ipmon(time_t facilitytime, char *ifptr)
}
if (pkt.iphdr)
- updateentry(&table, tcpentry, transpacket,
- pkt.pkt_buf, pkt.from->sll_hatype,
- pkt.pkt_len, br, pkt.iphdr->frag_off,
- logging, &revlook, rvnfd,
- logfile);
+ updateentry(&table, &pkt, tcpentry, transpacket,
+ br, pkt.iphdr->frag_off,
+ &revlook, rvnfd,
+ logging, logfile);
else
- updateentry(&table, tcpentry, transpacket,
- pkt.pkt_buf, pkt.from->sll_hatype,
- pkt.pkt_len, pkt.pkt_len, 0, logging,
+ updateentry(&table, &pkt, tcpentry, transpacket,
+ pkt.pkt_len, 0,
&revlook, rvnfd,
- logfile);
+ logging, logfile);
/*
* Log first packet of a TCP connection except if
* it's a RST, which was already logged earlier in
diff --git a/src/tcptable.c b/src/tcptable.c
index e217b19..2fedefa 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -536,11 +536,10 @@ struct tcptableent *in_table(struct tcptable *table,
* Update the TCP status record should an applicable packet arrive.
*/
-void updateentry(struct tcptable *table, struct tcptableent *tableentry,
- struct tcphdr *transpacket, char *packet, int linkproto,
- unsigned long packetlength, unsigned int bcount,
- unsigned int fragofs, int logging, int *revlook, int rvnfd,
- FILE *logfile)
+void updateentry(struct tcptable *table, struct pkt_hdr *pkt,
+ struct tcptableent *tableentry, struct tcphdr *transpacket,
+ unsigned int bcount, unsigned int fragofs, int *revlook,
+ int rvnfd, int logging, FILE *logfile)
{
char msgstring[MSGSTRING_MAX];
char newmacaddr[18];
@@ -561,20 +560,16 @@ void updateentry(struct tcptable *table, struct tcptableent
*tableentry,
}
tableentry->pcount++;
tableentry->bcount += bcount;
- tableentry->psize = packetlength;
+ tableentry->psize = pkt->pkt_len;
tableentry->spanbr += bcount;
if (options.mac) {
memset(newmacaddr, 0, sizeof(newmacaddr));
-
- /* change updateentry to take struct pkt to remove this */
- if (linkproto == ARPHRD_ETHER) {
- convmacaddr((char *) (((struct ethhdr *) packet)->
- h_source), newmacaddr);
- } else if (linkproto == ARPHRD_FDDI) {
- convmacaddr((char *) (((struct fddihdr *) packet)->
- saddr), newmacaddr);
+ if (pkt->from->sll_hatype == ARPHRD_ETHER) {
+ convmacaddr((char *) pkt->ethhdr->h_source, newmacaddr);
+ } else if (pkt->from->sll_hatype == ARPHRD_FDDI) {
+ convmacaddr((char *) pkt->fddihdr->saddr, newmacaddr);
}
if (tableentry->smacaddr[0] != '\0') {
diff --git a/src/tcptable.h b/src/tcptable.h
index ec1711a..aca72a9 100644
--- a/src/tcptable.h
+++ b/src/tcptable.h
@@ -7,6 +7,7 @@
***/
+#include "packet.h"
#include "rate.h"
/*
@@ -116,11 +117,10 @@ struct tcptableent *in_table(struct tcptable *table,
char *ifname, int logging,
FILE *logfile, time_t timeout);
-void updateentry(struct tcptable *table, struct tcptableent *tableentry,
- struct tcphdr *transpacket, char *packet, int linkproto,
- unsigned long packetlength, unsigned int bcount,
- unsigned int fragofs, int logging, int *revlook, int rvnfd,
- FILE *logfile);
+void updateentry(struct tcptable *table, struct pkt_hdr *pkt,
+ struct tcptableent *tableentry, struct tcphdr *transpacket,
+ unsigned int bcount, unsigned int fragofs, int *revlook,
+ int rvnfd, int logging, FILE *logfile);
void addtoclosedlist(struct tcptable *table, struct tcptableent *tableentry);
--
1.9.1