From f2699b76c89a5be1ef6411f29a57b4cccc59fa17 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 3 May 2019 13:29:20 -0700 Subject: Support IPv4 fragmentation in netstack Testing: Unit tests and also large ping in Fuchsia OS PiperOrigin-RevId: 246563592 Change-Id: Ia12ab619f64f4be2c8d346ce81341a91724aef95 --- pkg/tcpip/buffer/prependable.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/tcpip/buffer') diff --git a/pkg/tcpip/buffer/prependable.go b/pkg/tcpip/buffer/prependable.go index 43cbbc74c..4287464f3 100644 --- a/pkg/tcpip/buffer/prependable.go +++ b/pkg/tcpip/buffer/prependable.go @@ -52,6 +52,16 @@ func (p Prependable) UsedLength() int { return len(p.buf) - p.usedIdx } +// AvailableLength returns the number of bytes used so far. +func (p Prependable) AvailableLength() int { + return p.usedIdx +} + +// TrimBack removes size bytes from the end. +func (p *Prependable) TrimBack(size int) { + p.buf = p.buf[:len(p.buf)-size] +} + // Prepend reserves the requested space in front of the buffer, returning a // slice that represents the reserved space. func (p *Prependable) Prepend(size int) []byte { -- cgit v1.2.3