From 5bb64ce1b8c42fcd96e44a5be05e17f34a83f840 Mon Sep 17 00:00:00 2001 From: Nayana Bidari Date: Thu, 12 Nov 2020 22:55:09 -0800 Subject: Refactor SOL_SOCKET options Store all the socket level options in a struct and call {Get/Set}SockOpt on this struct. This will avoid implementing socket level options on all endpoints. This CL contains implementing one socket level option for tcp and udp endpoints. PiperOrigin-RevId: 342203981 --- pkg/tcpip/transport/raw/endpoint.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'pkg/tcpip/transport/raw') diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go index 7b6a87ba9..4ae1f92ab 100644 --- a/pkg/tcpip/transport/raw/endpoint.go +++ b/pkg/tcpip/transport/raw/endpoint.go @@ -89,6 +89,9 @@ type endpoint struct { // owner is used to get uid and gid of the packet. owner tcpip.PacketOwner + + // ops is used to get socket level options. + ops tcpip.SocketOptions } // NewEndpoint returns a raw endpoint for the given protocols. @@ -756,3 +759,7 @@ func (*endpoint) Wait() {} func (*endpoint) LastError() *tcpip.Error { return nil } + +func (e *endpoint) SocketOptions() *tcpip.SocketOptions { + return &e.ops +} -- cgit v1.2.3