Source file src/vendor/golang.org/x/net/quic/udp_linux.go

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build linux
     6  
     7  package quic
     8  
     9  import (
    10  	"syscall"
    11  )
    12  
    13  const (
    14  	ip_recvtos       = syscall.IP_RECVTOS
    15  	ipv6_recvpktinfo = syscall.IPV6_RECVPKTINFO
    16  	ipv6_pktinfo     = syscall.IPV6_PKTINFO
    17  )
    18  
    19  // See udp.go.
    20  const (
    21  	udpECNSupport              = true
    22  	udpInvalidLocalAddrIsError = false
    23  )
    24  
    25  // The IP_TOS socket option is a single byte containing the IP TOS field.
    26  // The low two bits are the ECN field.
    27  
    28  func parseIPTOS(b []byte) (ecnBits, bool) {
    29  	if len(b) != 1 {
    30  		return 0, false
    31  	}
    32  	return ecnBits(b[0] & ecnMask), true
    33  }
    34  
    35  func appendCmsgECNv4(b []byte, ecn ecnBits) []byte {
    36  	b, data := appendCmsg(b, syscall.IPPROTO_IP, syscall.IP_TOS, 1)
    37  	data[0] = byte(ecn)
    38  	return b
    39  }
    40  

View as plain text