11package proto
22
3+ // TCPPacket represents a TCP packet.
34type TCPPacket struct {
45 SourcePort uint16 `json:"sourcePort"`
56 DestinationPort uint16 `json:"destinationPort"`
@@ -23,38 +24,47 @@ type TCPPacket struct {
2324
2425const minTCPPacketSize = 2 + 2 + 4 + 4 + 1 + 2 + 2 + 2 + 2
2526
27+ // HasFIN returns true if the FIN flag is set.
2628func (p TCPPacket ) HasFIN () bool {
2729 return p .Flags & (1 << 0 ) > 0
2830}
2931
32+ // HasSYN returns true if the SYN flag is set.
3033func (p TCPPacket ) HasSYN () bool {
3134 return p .Flags & (1 << 1 ) > 0
3235}
3336
37+ // HasRST return true if the RST flag is set.
3438func (p TCPPacket ) HasRST () bool {
3539 return p .Flags & (1 << 2 ) > 0
3640}
3741
42+ // HasPSH returns true if the PSH flag is set.
3843func (p TCPPacket ) HasPSH () bool {
3944 return p .Flags & (1 << 3 ) > 0
4045}
4146
47+ // HasACK returns true if the ACK flag is set.
4248func (p TCPPacket ) HasACK () bool {
4349 return p .Flags & (1 << 4 ) > 0
4450}
4551
52+ // HasURG returns true if the URG flag is set.
4653func (p TCPPacket ) HasURG () bool {
4754 return p .Flags & (1 << 5 ) > 0
4855}
4956
57+ // HasECE returns true if the ECE flag is set.
5058func (p TCPPacket ) HasECE () bool {
5159 return p .Flags & (1 << 6 ) > 0
5260}
5361
62+ // HasCWR returns true if the CWR flag is set.
5463func (p TCPPacket ) HasCWR () bool {
5564 return p .Flags & (1 << 7 ) > 0
5665}
5766
67+ // HasNS returns true if the NS flag is set.
5868func (p TCPPacket ) HasNS () bool {
5969 return p .Flags >> 8 > 0
6070}
0 commit comments