From c006b9b1c813089f22ae979fb3198227be25c20a Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 26 May 2021 12:16:36 -0700 Subject: Move presence methods from segment to TCPFlags PiperOrigin-RevId: 376001032 --- pkg/tcpip/header/tcp.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/tcpip/header') diff --git a/pkg/tcpip/header/tcp.go b/pkg/tcpip/header/tcp.go index 0df517000..8dabe3354 100644 --- a/pkg/tcpip/header/tcp.go +++ b/pkg/tcpip/header/tcp.go @@ -48,6 +48,16 @@ const ( // TCPFlags is the dedicated type for TCP flags. type TCPFlags uint8 +// Intersects returns true iff there are flags common to both f and o. +func (f TCPFlags) Intersects(o TCPFlags) bool { + return f&o != 0 +} + +// Contains returns true iff all the flags in o are contained within f. +func (f TCPFlags) Contains(o TCPFlags) bool { + return f&o == o +} + // String implements Stringer.String. func (f TCPFlags) String() string { flagsStr := []byte("FSRPAU") -- cgit v1.2.3