Debian Codegraph @

abi/linux/errqueue.go

raw symbols SCIP
1 // Copyright 2020 The gVisor Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package linux
16
17 import (
18 "inet.af/netstack/marshal"
19 )
20
21 // Socket error origin codes as defined in include/uapi/linux/errqueue.h.
22 const (
23 SO_EE_ORIGIN_NONE = 0
24 SO_EE_ORIGIN_LOCAL = 1
25 SO_EE_ORIGIN_ICMP = 2
26 SO_EE_ORIGIN_ICMP6 = 3
27 )
28
29 // SockExtendedErr represents struct sock_extended_err in Linux defined in
30 // include/uapi/linux/errqueue.h.
31 //
32 // +marshal
33 type SockExtendedErr struct {
34 Errno uint32
35 Origin uint8
36 Type uint8
37 Code uint8
38 Pad uint8
39 Info uint32
40 Data uint32
41 }
42
43 // SockErrCMsg represents the IP*_RECVERR control message.
44 type SockErrCMsg interface {
45 marshal.Marshallable
46
47 CMsgLevel() uint32
48 CMsgType() uint32
49 }
50
51 // SockErrCMsgIPv4 is the IP_RECVERR control message used in
52 // recvmsg(MSG_ERRQUEUE) by ipv4 sockets. This is equilavent to `struct errhdr`
53 // defined in net/ipv4/ip_sockglue.c:ip_recv_error().
54 //
55 // +marshal
56 type SockErrCMsgIPv4 struct {
57 SockExtendedErr
58 Offender SockAddrInet
59 }
60
61 var _ SockErrCMsg = (*SockErrCMsgIPv4)(nil)
62
63 // CMsgLevel implements SockErrCMsg.CMsgLevel.
64 func (*SockErrCMsgIPv4) CMsgLevel() uint32 {
65 return SOL_IP
66 }
67
68 // CMsgType implements SockErrCMsg.CMsgType.
69 func (*SockErrCMsgIPv4) CMsgType() uint32 {
70 return IP_RECVERR
71 }
72
73 // SockErrCMsgIPv6 is the IPV6_RECVERR control message used in
74 // recvmsg(MSG_ERRQUEUE) by ipv6 sockets. This is equilavent to `struct errhdr`
75 // defined in net/ipv6/datagram.c:ipv6_recv_error().
76 //
77 // +marshal
78 type SockErrCMsgIPv6 struct {
79 SockExtendedErr
80 Offender SockAddrInet6
81 }
82
83 var _ SockErrCMsg = (*SockErrCMsgIPv6)(nil)
84
85 // CMsgLevel implements SockErrCMsg.CMsgLevel.
86 func (*SockErrCMsgIPv6) CMsgLevel() uint32 {
87 return SOL_IPV6
88 }
89
90 // CMsgType implements SockErrCMsg.CMsgType.
91 func (*SockErrCMsgIPv6) CMsgType() uint32 {
92 return IPV6_RECVERR
93 }