summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/header
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tcpip/header')
-rw-r--r--pkg/tcpip/header/BUILD1
-rw-r--r--pkg/tcpip/header/tcp.go11
2 files changed, 12 insertions, 0 deletions
diff --git a/pkg/tcpip/header/BUILD b/pkg/tcpip/header/BUILD
index 66b37720c..8e455fe1e 100644
--- a/pkg/tcpip/header/BUILD
+++ b/pkg/tcpip/header/BUILD
@@ -24,6 +24,7 @@ go_library(
"//pkg/tcpip",
"//pkg/tcpip/buffer",
"//pkg/tcpip/seqnum",
+ "@com_github_google_btree//:go_default_library",
],
)
diff --git a/pkg/tcpip/header/tcp.go b/pkg/tcpip/header/tcp.go
index 567a21167..207046b36 100644
--- a/pkg/tcpip/header/tcp.go
+++ b/pkg/tcpip/header/tcp.go
@@ -17,6 +17,7 @@ package header
import (
"encoding/binary"
+ "github.com/google/btree"
"gvisor.googlesource.com/gvisor/pkg/tcpip"
"gvisor.googlesource.com/gvisor/pkg/tcpip/seqnum"
)
@@ -131,6 +132,16 @@ type SACKBlock struct {
End seqnum.Value
}
+// Less returns true if r.Start < b.Start.
+func (r SACKBlock) Less(b btree.Item) bool {
+ return r.Start.LessThan(b.(SACKBlock).Start)
+}
+
+// Contains returns true if b is completely contained in r.
+func (r SACKBlock) Contains(b SACKBlock) bool {
+ return r.Start.LessThanEq(b.Start) && b.End.LessThanEq(r.End)
+}
+
// TCPOptions are used to parse and cache the TCP segment options for a non
// syn/syn-ack segment.
//