summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/header/eth.go
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2019-10-21 13:21:58 -0700
committergVisor bot <gvisor-bot@google.com>2019-10-21 13:23:18 -0700
commit12235d533ae5c8b4b03c6d7f24cae785a2d6ec22 (patch)
tree5abb8c6990f18af17a3889de637befc88b302a8e /pkg/tcpip/header/eth.go
parent652f7b1d0fef6f522baaed091d4820a48014092c (diff)
AF_PACKET support for netstack (aka epsocket).
Like (AF_INET, SOCK_RAW) sockets, AF_PACKET sockets require CAP_NET_RAW. With runsc, you'll need to pass `--net-raw=true` to enable them. Binding isn't supported yet. PiperOrigin-RevId: 275909366
Diffstat (limited to 'pkg/tcpip/header/eth.go')
-rw-r--r--pkg/tcpip/header/eth.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/tcpip/header/eth.go b/pkg/tcpip/header/eth.go
index 4c3d3311f..1bb3bb5e6 100644
--- a/pkg/tcpip/header/eth.go
+++ b/pkg/tcpip/header/eth.go
@@ -50,6 +50,24 @@ const (
EthernetAddressSize = 6
)
+const (
+ // EthernetProtocolAll is a catch-all for all protocols carried inside
+ // an ethernet frame. It is mainly used to create packet sockets that
+ // capture all traffic.
+ EthernetProtocolAll tcpip.NetworkProtocolNumber = 0x0003
+
+ // EthernetProtocolPUP is the PARC Universial Packet protocol ethertype.
+ EthernetProtocolPUP tcpip.NetworkProtocolNumber = 0x0200
+)
+
+// Ethertypes holds the protocol numbers describing the payload of an ethernet
+// frame. These types aren't necessarily supported by netstack, but can be used
+// to catch all traffic of a type via packet endpoints.
+var Ethertypes = []tcpip.NetworkProtocolNumber{
+ EthernetProtocolAll,
+ EthernetProtocolPUP,
+}
+
// SourceAddress returns the "MAC source" field of the ethernet frame header.
func (b Ethernet) SourceAddress() tcpip.LinkAddress {
return tcpip.LinkAddress(b[srcMAC:][:EthernetAddressSize])