summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/udp/protocol.go
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2019-09-25 12:56:00 -0700
committergVisor bot <gvisor-bot@google.com>2019-09-25 12:57:05 -0700
commit59ccbb10446063f5347fb026e35549bc2f677971 (patch)
tree375679720cfe149976d0f06f7d6d9aa727f780b0 /pkg/tcpip/transport/udp/protocol.go
parent99c86b8dbdaaaba8724d9946d3137c5f9303d51e (diff)
Remove centralized registration of protocols.
Also removes the need for protocol names. PiperOrigin-RevId: 271186030
Diffstat (limited to 'pkg/tcpip/transport/udp/protocol.go')
-rw-r--r--pkg/tcpip/transport/udp/protocol.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/pkg/tcpip/transport/udp/protocol.go b/pkg/tcpip/transport/udp/protocol.go
index 068d9a272..f5cc932dd 100644
--- a/pkg/tcpip/transport/udp/protocol.go
+++ b/pkg/tcpip/transport/udp/protocol.go
@@ -14,7 +14,7 @@
// Package udp contains the implementation of the UDP transport protocol. To use
// it in the networking stack, this package must be added to the project, and
-// activated on the stack by passing udp.ProtocolName (or "udp") as one of the
+// activated on the stack by passing udp.NewProtocol() as one of the
// transport protocols when calling stack.New(). Then endpoints can be created
// by passing udp.ProtocolNumber as the transport protocol number when calling
// Stack.NewEndpoint().
@@ -30,9 +30,6 @@ import (
)
const (
- // ProtocolName is the string representation of the udp protocol name.
- ProtocolName = "udp"
-
// ProtocolNumber is the udp protocol number.
ProtocolNumber = header.UDPProtocolNumber
)
@@ -182,8 +179,7 @@ func (p *protocol) Option(option interface{}) *tcpip.Error {
return tcpip.ErrUnknownProtocolOption
}
-func init() {
- stack.RegisterTransportProtocolFactory(ProtocolName, func() stack.TransportProtocol {
- return &protocol{}
- })
+// NewProtocol returns a UDP transport protocol.
+func NewProtocol() stack.TransportProtocol {
+ return &protocol{}
}