From 6e97bcdf505f60c362e4ba7cc648d3b6f9e3fa18 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 23 Jan 2021 02:19:03 +0100 Subject: decode gre protocol type --- pkg/tcpip/header/gre.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pkg/tcpip/header') diff --git a/pkg/tcpip/header/gre.go b/pkg/tcpip/header/gre.go index 65f5c1894..326d03ba8 100644 --- a/pkg/tcpip/header/gre.go +++ b/pkg/tcpip/header/gre.go @@ -1,8 +1,8 @@ package header import ( - "encoding/binary" - + "encoding/binary" + "gvisor.dev/gvisor/pkg/tcpip" ) @@ -18,6 +18,11 @@ const ( GREProtocolNumber tcpip.TransportProtocolNumber = 47 ) +func (b GRE) ProtocolType() tcpip.NetworkProtocolNumber { + proto := binary.BigEndian.Uint16(b[greProtocolType:]) + return tcpip.NetworkProtocolNumber(proto) +} + // SetLength sets the "length" field of the udp header. func (b GRE) SetProtocolType(protocol tcpip.NetworkProtocolNumber) { binary.BigEndian.PutUint16(b[greProtocolType:], uint16(protocol)) -- cgit v1.2.3