Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/log.c | 44 --------------------------------------------
src/tcptable.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
src/tcptable.h | 5 +++++
3 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/src/log.c b/src/log.c
index 27f58e5..83b19f7 100644
--- a/src/log.c
+++ b/src/log.c
@@ -142,50 +142,6 @@ void write_daemon_err(char *msg, va_list vararg)
fclose(fd);
}
-void writetcplog(int logging, FILE * fd, struct tcptableent *entry,
- unsigned int pktlen, int mac, char *message)
-{
- char msgbuf[MSGSTRING_MAX];
-
- if (logging) {
- if (mac) {
- snprintf(msgbuf, MSGSTRING_MAX,
- "TCP; %s; %u bytes; from %s:%s to %s:%s (source MAC addr %s); %s",
- entry->ifname, pktlen, entry->s_fqdn,
- entry->s_sname, entry->d_fqdn, entry->d_sname,
- entry->smacaddr, message);
- } else {
- snprintf(msgbuf, MSGSTRING_MAX,
- "TCP; %s; %u bytes; from %s:%s to %s:%s; %s",
- entry->ifname, pktlen, entry->s_fqdn,
- entry->s_sname, entry->d_fqdn, entry->d_sname,
- message);
- }
-
- writelog(logging, fd, msgbuf);
- }
-}
-
-void write_tcp_unclosed(int logging, FILE * fd, struct tcptable *table)
-{
- char msgbuf[MSGSTRING_MAX];
-
- struct tcptableent *entry = table->head;
-
- while (entry != NULL) {
- if ((entry->finsent == 0) && ((entry->stat & FLAG_RST) == 0)
- && (!(entry->inclosed))) {
- sprintf(msgbuf,
- "TCP; %s; active; from %s:%s to %s:%s; %lu packets, %lu bytes",
- entry->ifname, entry->s_fqdn, entry->s_sname,
- entry->d_fqdn, entry->d_sname, entry->pcount,
- entry->bcount);
- writelog(logging, fd, msgbuf);
- }
- entry = entry->next_entry;
- }
-}
-
void rotate_logfile(FILE ** fd, char *name)
{
fclose(*fd);
diff --git a/src/tcptable.c b/src/tcptable.c
index 63123a2..c9539b7 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -34,8 +34,6 @@ unsigned int bmaxy = 0;
unsigned int imaxy = 0;
void convmacaddr(char *addr, char *result);
-void writetcplog(int logging, FILE * fd, struct tcptableent *entry,
- unsigned int pktlen, int mac, char *message);
void setlabels(WINDOW * win, int mode)
{
@@ -1208,3 +1206,47 @@ void flushclosedentries(struct tcptable *table, unsigned long
*screen_idx,
table->baridx = table->barptr->index - *screen_idx + 1;
}
}
+
+void writetcplog(int logging, FILE *fd, struct tcptableent *entry,
+ unsigned int pktlen, int mac, char *message)
+{
+ char msgbuf[MSGSTRING_MAX];
+
+ if (logging) {
+ if (mac) {
+ snprintf(msgbuf, MSGSTRING_MAX,
+ "TCP; %s; %u bytes; from %s:%s to %s:%s (source MAC addr %s); %s",
+ entry->ifname, pktlen, entry->s_fqdn,
+ entry->s_sname, entry->d_fqdn, entry->d_sname,
+ entry->smacaddr, message);
+ } else {
+ snprintf(msgbuf, MSGSTRING_MAX,
+ "TCP; %s; %u bytes; from %s:%s to %s:%s; %s",
+ entry->ifname, pktlen, entry->s_fqdn,
+ entry->s_sname, entry->d_fqdn, entry->d_sname,
+ message);
+ }
+
+ writelog(logging, fd, msgbuf);
+ }
+}
+
+void write_tcp_unclosed(int logging, FILE *fd, struct tcptable *table)
+{
+ char msgbuf[MSGSTRING_MAX];
+
+ struct tcptableent *entry = table->head;
+
+ while (entry != NULL) {
+ if ((entry->finsent == 0) && ((entry->stat & FLAG_RST) == 0)
+ && (!(entry->inclosed))) {
+ sprintf(msgbuf,
+ "TCP; %s; active; from %s:%s to %s:%s; %lu packets, %lu bytes",
+ entry->ifname, entry->s_fqdn, entry->s_sname,
+ entry->d_fqdn, entry->d_sname, entry->pcount,
+ entry->bcount);
+ writelog(logging, fd, msgbuf);
+ }
+ entry = entry->next_entry;
+ }
+}
diff --git a/src/tcptable.h b/src/tcptable.h
index 5e3e8cf..e30917d 100644
--- a/src/tcptable.h
+++ b/src/tcptable.h
@@ -133,4 +133,9 @@ void flushclosedentries(struct tcptable *table, unsigned long
*screen_idx,
void write_timeout_log(int logging, FILE * logfile, struct tcptableent *tcpnode,
struct OPTIONS *opts);
+void writetcplog(int logging, FILE *fd, struct tcptableent *entry,
+ unsigned int pktlen, int mac, char *message);
+
+void write_tcp_unclosed(int logging, FILE *fd, struct tcptable *table);
+
#endif /* IPTRAF_NG_TCPTABLE_H */
--
1.7.8.4