File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ import "net/netip"
66const SocketControlMessageBufferSize = socketControlMessageBufferSize
77
88// SocketControlMessage contains information that can be parsed from or put into socket control messages.
9+ //
10+ // Fields of [Pktinfo] are manually embedded to avoid wasting space.
911type SocketControlMessage struct {
10- // PktinfoAddr is the IP address of the network interface the packet was received from.
12+ // PktinfoAddr is the IP address of the network interface the packet was received on, or to send the packet from.
1113 PktinfoAddr netip.Addr
1214
13- // PktinfoIfindex is the index of the network interface the packet was received from.
15+ // PktinfoIfindex is the index of the network interface the packet was received on, or to send the packet from.
1416 PktinfoIfindex uint32
1517
1618 // SegmentSize is the UDP GRO/GSO segment size.
@@ -29,3 +31,16 @@ func ParseSocketControlMessage(cmsg []byte) (m SocketControlMessage, err error)
2931func (m SocketControlMessage ) AppendTo (b []byte ) []byte {
3032 return m .appendTo (b )
3133}
34+
35+ // Pktinfo represents packet information as specified in RFC 3542.
36+ //
37+ // For received packets, it contains the destination IP address and the arriving interface index.
38+ //
39+ // For outgoing packets, it can specify the source IP address and the outgoing interface index.
40+ type Pktinfo struct {
41+ // Addr is the IP address of the network interface the packet was received on, or to send the packet from.
42+ Addr netip.Addr
43+
44+ // Ifindex is the index of the network interface the packet was received on, or to send the packet from.
45+ Ifindex uint32
46+ }
You can’t perform that action at this time.
0 commit comments