github.com/tumi8/quic-go@v0.37.4-tum/sys_conn_helper_freebsd.go (about)

     1  //go:build freebsd
     2  
     3  package quic
     4  
     5  import (
     6  	"net/netip"
     7  
     8  	"golang.org/x/sys/unix"
     9  )
    10  
    11  const (
    12  	msgTypeIPTOS = unix.IP_RECVTOS
    13  	ipv4PKTINFO  = 0x7
    14  )
    15  
    16  const batchSize = 8
    17  
    18  func parseIPv4PktInfo(body []byte) (ip netip.Addr, _ uint32, ok bool) {
    19  	// struct in_pktinfo {
    20  	// 	struct in_addr ipi_addr;     /* Header Destination address */
    21  	// };
    22  	if len(body) != 4 {
    23  		return netip.Addr{}, 0, false
    24  	}
    25  	return netip.AddrFrom4(*(*[4]byte)(body)), 0, true
    26  }