mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
55 lines
884 B
C++
55 lines
884 B
C++
#ifndef ANALYZER_PROTOCOL_TCP_TCP_FLAGS_H
|
|
#define ANALYZER_PROTOCOL_TCP_TCP_FLAGS_H
|
|
|
|
namespace analyzer { namespace tcp {
|
|
|
|
class TCP_Flags {
|
|
public:
|
|
TCP_Flags(const struct tcphdr* tp) { flags = tp->th_flags; }
|
|
TCP_Flags() { flags = 0; }
|
|
|
|
bool SYN() const { return flags & TH_SYN; }
|
|
bool FIN() const { return flags & TH_FIN; }
|
|
bool RST() const { return flags & TH_RST; }
|
|
bool ACK() const { return flags & TH_ACK; }
|
|
bool URG() const { return flags & TH_URG; }
|
|
bool PUSH() const { return flags & TH_PUSH; }
|
|
|
|
string AsString() const;
|
|
|
|
protected:
|
|
u_char flags;
|
|
};
|
|
|
|
inline string TCP_Flags::AsString() const
|
|
{
|
|
char tcp_flags[10];
|
|
char* p = tcp_flags;
|
|
|
|
if ( SYN() )
|
|
*p++ = 'S';
|
|
|
|
if ( FIN() )
|
|
*p++ = 'F';
|
|
|
|
if ( RST() )
|
|
*p++ = 'R';
|
|
|
|
if ( ACK() )
|
|
*p++ = 'A';
|
|
|
|
if ( PUSH() )
|
|
*p++ = 'P';
|
|
|
|
if ( URG() )
|
|
*p++ = 'U';
|
|
|
|
*p++ = '\0';
|
|
return tcp_flags;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endif
|