From a5acc0616c9552c7252e3f133f9ad4648422cc5f Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Mon, 28 Sep 2020 16:22:09 -0700 Subject: Support creating protocol instances with Stack ref Network or transport protocols may want to reach the stack. Support this by letting the stack create the protocol instances so it can pass a reference to itself at protocol creation time. Note, protocols do not yet use the stack in this CL but later CLs will make use of the stack from protocols. PiperOrigin-RevId: 334260210 --- pkg/tcpip/transport/icmp/protocol.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'pkg/tcpip/transport/icmp') diff --git a/pkg/tcpip/transport/icmp/protocol.go b/pkg/tcpip/transport/icmp/protocol.go index 941c3c08d..7484f4ad9 100644 --- a/pkg/tcpip/transport/icmp/protocol.go +++ b/pkg/tcpip/transport/icmp/protocol.go @@ -13,12 +13,7 @@ // limitations under the License. // Package icmp contains the implementation of the ICMP and IPv6-ICMP transport -// protocols for use in ping. To use it in the networking stack, this package -// must be added to the project, and activated on the stack by passing -// icmp.NewProtocol4() and/or icmp.NewProtocol6() as one of the transport -// protocols when calling stack.New(). Then endpoints can be created by passing -// icmp.ProtocolNumber or icmp.ProtocolNumber6 as the transport protocol number -// when calling Stack.NewEndpoint(). +// protocols for use in ping. package icmp import ( @@ -135,11 +130,11 @@ func (*protocol) Parse(pkt *stack.PacketBuffer) bool { } // NewProtocol4 returns an ICMPv4 transport protocol. -func NewProtocol4() stack.TransportProtocol { +func NewProtocol4(*stack.Stack) stack.TransportProtocol { return &protocol{ProtocolNumber4} } // NewProtocol6 returns an ICMPv6 transport protocol. -func NewProtocol6() stack.TransportProtocol { +func NewProtocol6(*stack.Stack) stack.TransportProtocol { return &protocol{ProtocolNumber6} } -- cgit v1.2.3