summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack/stack.go
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2019-04-02 11:12:29 -0700
committerShentubot <shentubot@google.com>2019-04-02 11:13:49 -0700
commit52a51a8e20b3e5c28eb1e66bd57203216cf644c5 (patch)
tree4d98f67dc4abb15e6de568b2af12a3e12f41aa99 /pkg/tcpip/stack/stack.go
parent1df3fa69977477092efa65a8de407bd6f0f88db4 (diff)
Add a raw socket transport endpoint and use it for raw ICMP sockets.
Having raw socket code together will make it easier to add support for other raw network protocols. Currently, only ICMP uses the raw endpoint. However, adding support for other protocols such as UDP shouldn't be much more difficult than adding a few switch cases. PiperOrigin-RevId: 241564875 Change-Id: I77e03adafe4ce0fd29ba2d5dfdc547d2ae8f25bf
Diffstat (limited to 'pkg/tcpip/stack/stack.go')
-rw-r--r--pkg/tcpip/stack/stack.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go
index 15a268b10..a74c0a7a0 100644
--- a/pkg/tcpip/stack/stack.go
+++ b/pkg/tcpip/stack/stack.go
@@ -955,11 +955,11 @@ func (s *Stack) UnregisterTransportEndpoint(nicID tcpip.NICID, netProtos []tcpip
}
// RegisterRawTransportEndpoint registers the given endpoint with the stack
-// transport dispatcher. Received packets that match the provided protocol will
-// be delivered to the given endpoint.
-func (s *Stack) RegisterRawTransportEndpoint(nicID tcpip.NICID, netProtos []tcpip.NetworkProtocolNumber, protocol tcpip.TransportProtocolNumber, ep TransportEndpoint, reusePort bool) *tcpip.Error {
+// transport dispatcher. Received packets that match the provided transport
+// protocol will be delivered to the given endpoint.
+func (s *Stack) RegisterRawTransportEndpoint(nicID tcpip.NICID, netProto tcpip.NetworkProtocolNumber, transProto tcpip.TransportProtocolNumber, ep RawTransportEndpoint) *tcpip.Error {
if nicID == 0 {
- return s.demux.registerRawEndpoint(netProtos, protocol, ep, reusePort)
+ return s.demux.registerRawEndpoint(netProto, transProto, ep)
}
s.mu.RLock()
@@ -970,14 +970,14 @@ func (s *Stack) RegisterRawTransportEndpoint(nicID tcpip.NICID, netProtos []tcpi
return tcpip.ErrUnknownNICID
}
- return nic.demux.registerRawEndpoint(netProtos, protocol, ep, reusePort)
+ return nic.demux.registerRawEndpoint(netProto, transProto, ep)
}
-// UnregisterRawTransportEndpoint removes the endpoint for the protocol from
-// the stack transport dispatcher.
-func (s *Stack) UnregisterRawTransportEndpoint(nicID tcpip.NICID, netProtos []tcpip.NetworkProtocolNumber, protocol tcpip.TransportProtocolNumber, ep TransportEndpoint) {
+// UnregisterRawTransportEndpoint removes the endpoint for the transport
+// protocol from the stack transport dispatcher.
+func (s *Stack) UnregisterRawTransportEndpoint(nicID tcpip.NICID, netProto tcpip.NetworkProtocolNumber, transProto tcpip.TransportProtocolNumber, ep RawTransportEndpoint) {
if nicID == 0 {
- s.demux.unregisterRawEndpoint(netProtos, protocol, ep)
+ s.demux.unregisterRawEndpoint(netProto, transProto, ep)
return
}
@@ -986,7 +986,7 @@ func (s *Stack) UnregisterRawTransportEndpoint(nicID tcpip.NICID, netProtos []tc
nic := s.nics[nicID]
if nic != nil {
- nic.demux.unregisterRawEndpoint(netProtos, protocol, ep)
+ nic.demux.unregisterRawEndpoint(netProto, transProto, ep)
}
}