diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-23 02:19:03 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-23 21:43:01 +0100 |
commit | 6e97bcdf505f60c362e4ba7cc648d3b6f9e3fa18 (patch) | |
tree | d3490b55665966c567c713288fefd206584b6fbd /pkg/tcpip/header | |
parent | b9db93d60492d7816fd6cc4201228ee35820a36d (diff) |
decode gre protocol type
Diffstat (limited to 'pkg/tcpip/header')
-rw-r--r-- | pkg/tcpip/header/gre.go | 9 |
1 files changed, 7 insertions, 2 deletions
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)) |