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