| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package noop |
| 18 |
|
| 19 |
import ( |
| 20 |
"fmt" |
| 21 |
"io" |
| 22 |
|
| 23 |
"inet.af/netstack/tcpip" |
| 24 |
"inet.af/netstack/tcpip/stack" |
| 25 |
"inet.af/netstack/waiter" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
type endpoint struct { |
| 33 |
tcpip.DefaultSocketOptionsHandler |
| 34 |
ops tcpip.SocketOptions |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
func New(stk *stack.Stack) tcpip.Endpoint { |
| 39 |
|
| 40 |
|
| 41 |
var ep endpoint |
| 42 |
ep.ops.InitHandler(&ep, stk, tcpip.GetStackSendBufferLimits, tcpip.GetStackReceiveBufferLimits) |
| 43 |
return &ep |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
func (*endpoint) Abort() { |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
func (*endpoint) Close() { |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
func (*endpoint) ModerateRecvBuf(int) { |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
func (*endpoint) SetOwner(tcpip.PacketOwner) { |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
func (*endpoint) Read(io.Writer, tcpip.ReadOptions) (tcpip.ReadResult, tcpip.Error) { |
| 67 |
return tcpip.ReadResult{}, &tcpip.ErrNotPermitted{} |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
func (*endpoint) Write(tcpip.Payloader, tcpip.WriteOptions) (int64, tcpip.Error) { |
| 72 |
return 0, &tcpip.ErrNotPermitted{} |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
func (*endpoint) Disconnect() tcpip.Error { |
| 77 |
return &tcpip.ErrNotSupported{} |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
func (*endpoint) Connect(tcpip.FullAddress) tcpip.Error { |
| 82 |
return &tcpip.ErrNotPermitted{} |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
func (*endpoint) Shutdown(tcpip.ShutdownFlags) tcpip.Error { |
| 87 |
return &tcpip.ErrNotPermitted{} |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
func (*endpoint) Listen(int) tcpip.Error { |
| 92 |
return &tcpip.ErrNotSupported{} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
func (*endpoint) Accept(*tcpip.FullAddress) (tcpip.Endpoint, *waiter.Queue, tcpip.Error) { |
| 97 |
return nil, nil, &tcpip.ErrNotSupported{} |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
func (*endpoint) Bind(tcpip.FullAddress) tcpip.Error { |
| 102 |
return &tcpip.ErrNotPermitted{} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
func (*endpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error) { |
| 107 |
return tcpip.FullAddress{}, &tcpip.ErrNotSupported{} |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
func (*endpoint) GetRemoteAddress() (tcpip.FullAddress, tcpip.Error) { |
| 112 |
return tcpip.FullAddress{}, &tcpip.ErrNotConnected{} |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
func (*endpoint) Readiness(waiter.EventMask) waiter.EventMask { |
| 117 |
return 0 |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
func (*endpoint) SetSockOpt(tcpip.SettableSocketOption) tcpip.Error { |
| 122 |
return &tcpip.ErrUnknownProtocolOption{} |
| 123 |
} |
| 124 |
|
| 125 |
func (*endpoint) SetSockOptInt(tcpip.SockOptInt, int) tcpip.Error { |
| 126 |
return &tcpip.ErrUnknownProtocolOption{} |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
func (*endpoint) GetSockOpt(tcpip.GettableSocketOption) tcpip.Error { |
| 131 |
return &tcpip.ErrUnknownProtocolOption{} |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
func (*endpoint) GetSockOptInt(tcpip.SockOptInt) (int, tcpip.Error) { |
| 136 |
return 0, &tcpip.ErrUnknownProtocolOption{} |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
func (*endpoint) HandlePacket(pkt *stack.PacketBuffer) { |
| 141 |
panic(fmt.Sprintf("unreachable: noop.endpoint should never be registered, but got packet: %+v", pkt)) |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
func (*endpoint) State() uint32 { |
| 146 |
return 0 |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
func (*endpoint) Wait() { |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
func (*endpoint) LastError() tcpip.Error { |
| 156 |
return nil |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
func (ep *endpoint) SocketOptions() *tcpip.SocketOptions { |
| 161 |
return &ep.ops |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
func (*endpoint) Info() tcpip.EndpointInfo { |
| 166 |
return &stack.TransportEndpointInfo{} |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
func (*endpoint) Stats() tcpip.EndpointStats { |
| 171 |
return &tcpip.TransportEndpointStats{} |
| 172 |
} |