1 #ifndef IPTRAF_NG_TCPTABLE_H
2 #define IPTRAF_NG_TCPTABLE_H
6 tcptable.h -- table manipulation for the statistics display.
14 * max() macros that also do
15 * strict type-checking.. See the
16 * "unnecessary" pointer comparison.
18 #define max(x, y) ({ \
19 typeof(x) _max1 = (x); \
20 typeof(y) _max2 = (y); \
21 (void) (&_max1 == &_max2); \
22 _max1 > _max2 ? _max1 : _max2; })
32 #define ENTRIES_IN_HASH_TABLE 1543
35 struct sockaddr_storage saddr
;
36 struct sockaddr_storage daddr
;
37 char s_fqdn
[45]; /* fully-qualified domain names */
42 char s_sname
[11]; /* Service names, maxlen=10 */
44 unsigned int protocol
;
45 unsigned long pcount
; /* packet count */
46 unsigned long bcount
; /* byte count */
47 unsigned int stat
; /* TCP flags */
53 char ifname
[IFNAMSIZ
];
62 time_t conn_starttime
;
63 struct tcp_hashentry
*hash_node
;
64 struct tcptableent
*oth_connection
; /* the other half of the connection */
65 struct tcptableent
*prev_entry
;
66 struct tcptableent
*next_entry
;
70 struct tcptableent
*closedentry
;
71 struct tcptableent
*pair
;
72 struct closedlist
*next_entry
;
75 struct tcp_hashentry
{
77 unsigned int hp
; /* index position in bucket array */
78 struct tcptableent
*tcpnode
;
79 struct tcp_hashentry
*prev_entry
;
80 struct tcp_hashentry
*next_entry
;
84 struct tcp_hashentry
*hash_table
[ENTRIES_IN_HASH_TABLE
];
85 struct tcp_hashentry
*hash_tails
[ENTRIES_IN_HASH_TABLE
];
86 struct tcptableent
*head
;
87 struct tcptableent
*tail
;
88 struct closedlist
*closedentries
;
89 struct closedlist
*closedtail
;
90 struct tcptableent
*firstvisible
;
91 struct tcptableent
*lastvisible
;
92 struct tcptableent
*barptr
;
95 unsigned int bmaxy
; /* number of lines of the border window */
96 unsigned int imaxy
; /* number of lines inside the border */
97 int ifnamew
; /* interface name width to display */
108 void show_stats(WINDOW
*win
, unsigned long long total
);
110 void init_tcp_table(struct tcptable
*table
);
112 struct tcptableent
*addentry(struct tcptable
*table
,
113 struct sockaddr_storage
*saddr
,
114 struct sockaddr_storage
*daddr
,
115 int protocol
, char *ifname
,
116 int *rev_lookup
, int rvnamedon
);
118 void mark_timeouted_entries(struct tcptable
*table
, int logging
, FILE *logfile
);
120 struct tcptableent
*in_table(struct tcptable
*table
,
121 struct sockaddr_storage
*saddr
,
122 struct sockaddr_storage
*daddr
,
125 void updateentry(struct tcptable
*table
, struct pkt_hdr
*pkt
,
126 struct tcptableent
*tableentry
, struct tcphdr
*transpacket
,
127 unsigned int bcount
, int *revlook
, int rvnfd
, int logging
,
130 void addtoclosedlist(struct tcptable
*table
, struct tcptableent
*tableentry
);
132 void clearaddr(struct tcptable
*table
, struct tcptableent
*tableentry
);
134 void printentry(struct tcptable
*table
, struct tcptableent
*tableentry
);
136 void refreshtcpwin(struct tcptable
*table
);
138 void destroytcptable(struct tcptable
*table
);
140 void flushclosedentries(struct tcptable
*table
);
142 void write_timeout_log(int logging
, FILE *logfile
, struct tcptableent
*tcpnode
);
144 void writetcplog(int logging
, FILE *fd
, struct tcptableent
*entry
,
145 unsigned int pktlen
, char *message
);
147 void write_tcp_unclosed(int logging
, FILE *fd
, struct tcptable
*table
);
149 #endif /* IPTRAF_NG_TCPTABLE_H */