forked from quic-go/quic-go
simplify syscall consts used for requesting / parsing IPv4 packet info (#3919)
This commit is contained in:
@@ -6,8 +6,7 @@ import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
msgTypeIPTOS = unix.IP_RECVTOS
|
||||
ipv4RECVPKTINFO = unix.IP_RECVPKTINFO
|
||||
msgTypeIPv4PKTINFO = unix.IP_PKTINFO
|
||||
ipv4PKTINFO = unix.IP_RECVPKTINFO
|
||||
)
|
||||
|
||||
// ReadBatch only returns a single packet on OSX,
|
||||
|
||||
@@ -6,8 +6,7 @@ import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
msgTypeIPTOS = unix.IP_RECVTOS
|
||||
ipv4RECVPKTINFO = 0x7
|
||||
msgTypeIPv4PKTINFO = 0x7
|
||||
ipv4PKTINFO = 0x7
|
||||
)
|
||||
|
||||
const batchSize = 8
|
||||
|
||||
@@ -10,8 +10,7 @@ import (
|
||||
|
||||
const (
|
||||
msgTypeIPTOS = unix.IP_TOS
|
||||
ipv4RECVPKTINFO = unix.IP_PKTINFO
|
||||
msgTypeIPv4PKTINFO = unix.IP_PKTINFO
|
||||
ipv4PKTINFO = unix.IP_PKTINFO
|
||||
)
|
||||
|
||||
const batchSize = 8 // needs to smaller than MaxUint8 (otherwise the type of oobConn.readPos has to be changed)
|
||||
|
||||
@@ -87,7 +87,7 @@ func newConn(c OOBCapablePacketConn, supportsDF bool) (*oobConn, error) {
|
||||
errECNIPv6 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVTCLASS, 1)
|
||||
|
||||
if needsPacketInfo {
|
||||
errPIIPv4 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, ipv4RECVPKTINFO, 1)
|
||||
errPIIPv4 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, ipv4PKTINFO, 1)
|
||||
errPIIPv6 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1)
|
||||
}
|
||||
}); err != nil {
|
||||
@@ -188,7 +188,7 @@ func (c *oobConn) ReadPacket() (receivedPacket, error) {
|
||||
switch hdr.Type {
|
||||
case msgTypeIPTOS:
|
||||
p.ecn = protocol.ECN(body[0] & ecnMask)
|
||||
case msgTypeIPv4PKTINFO:
|
||||
case ipv4PKTINFO:
|
||||
// struct in_pktinfo {
|
||||
// unsigned int ipi_ifindex; /* Interface index */
|
||||
// struct in_addr ipi_spec_dst; /* Local address */
|
||||
|
||||
Reference in New Issue
Block a user