mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
simplify tcp flag checks, fix stream_follower (#334)
* simplify tcp flag checks, fix stream_follower On various places was used simple comparison for checking state of flags. tcp.flags() == (TCP::SYN | TCP::ACK) This is not what you want usually, because this check is false in case that another flag is set also. Correct check for syn-ack packet should be: (tcp.flags() & (TCP::SYN | TCP::ACK)) == (TCP::SYN | TCP::ACK) To simplify this kind of check, add new has_flags method: bool TCP::has_flags(small_uint<12> check_flags) const * remove duplicate TCP::SYN flag check
This commit is contained in:
committed by
Matias Fontanini
parent
74e3d909e6
commit
22b4435c81
@@ -116,7 +116,7 @@ bool Scanner::callback(PDU& pdu) {
|
||||
cout << "Port: " << setw(5) << tcp.sport() << " closed\n";
|
||||
}
|
||||
// Is SYN flag on? Then port is open!
|
||||
else if(tcp.flags() == (TCP::SYN | TCP::ACK)) {
|
||||
else if(tcp.has_flags(TCP::SYN | TCP::ACK)) {
|
||||
cout << "Port: " << setw(5) << tcp.sport() << " open\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user