NetFlow: Use tcp_flag_values[] for TCP flags.

This way there is less code duplication and more consistency.
This commit is contained in:
Denis Ovsienko 2021-01-16 10:56:30 +00:00
parent 5eb88b81d2
commit f72772154c
4 changed files with 9 additions and 25 deletions

View File

@ -9,6 +9,7 @@ Monthday, Month DD, YYYY by gharris and denis
AppleTalk: Declutter appletalk.h.
OpenFlow 1.0: Fix indentation of PORT_MOD.
RIP: Make a couple trivial protocol updates.
NetFlow: Use tcp_flag_values[] for TCP flags.
Monthday, Month DD, YYYY by gharris
Summary for 4.99.1 tcpdump release (so far!)

View File

@ -226,14 +226,8 @@ cnfp_v1_print(netdissect_options *ndo, const u_char *cp)
if (proto == IPPROTO_TCP) {
u_int flags;
flags = GET_U_1(nr->tcp_flags);
ND_PRINT("%s%s%s%s%s%s%s",
flags & TH_FIN ? "F" : "",
flags & TH_SYN ? "S" : "",
flags & TH_RST ? "R" : "",
flags & TH_PUSH ? "P" : "",
flags & TH_ACK ? "A" : "",
flags & TH_URG ? "U" : "",
flags ? " " : "");
if (flags)
ND_PRINT("%s ", bittok2str_nosep(tcp_flag_values, "", flags));
}
buf[0]='\0';
@ -328,14 +322,8 @@ cnfp_v5_print(netdissect_options *ndo, const u_char *cp)
if (proto == IPPROTO_TCP) {
u_int flags;
flags = GET_U_1(nr->tcp_flags);
ND_PRINT("%s%s%s%s%s%s%s",
flags & TH_FIN ? "F" : "",
flags & TH_SYN ? "S" : "",
flags & TH_RST ? "R" : "",
flags & TH_PUSH ? "P" : "",
flags & TH_ACK ? "A" : "",
flags & TH_URG ? "U" : "",
flags ? " " : "");
if (flags)
ND_PRINT("%s ", bittok2str_nosep(tcp_flag_values, "", flags));
}
buf[0]='\0';
@ -430,14 +418,8 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
if (proto == IPPROTO_TCP) {
u_int flags;
flags = GET_U_1(nr->tcp_flags);
ND_PRINT("%s%s%s%s%s%s%s",
flags & TH_FIN ? "F" : "",
flags & TH_SYN ? "S" : "",
flags & TH_RST ? "R" : "",
flags & TH_PUSH ? "P" : "",
flags & TH_ACK ? "A" : "",
flags & TH_URG ? "U" : "",
flags ? " " : "");
if (flags)
ND_PRINT("%s ", bittok2str_nosep(tcp_flag_values, "", flags));
}
buf[0]='\0';

View File

@ -101,7 +101,7 @@ struct tcp_seq_hash6 {
static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE];
static const struct tok tcp_flag_values[] = {
const struct tok tcp_flag_values[] = {
{ TH_FIN, "F" },
{ TH_SYN, "S" },
{ TH_RST, "R" },

1
tcp.h
View File

@ -60,6 +60,7 @@ struct tcphdr {
#define TH_URG 0x20
#define TH_ECNECHO 0x40 /* ECN Echo */
#define TH_CWR 0x80 /* ECN Cwnd Reduced */
extern const struct tok tcp_flag_values[];
#define TCPOPT_EOL 0