golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/quic/udp.go (about) 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 go1.21 6 7 package quic 8 9 import "net/netip" 10 11 // Per-plaform consts describing support for various features. 12 // 13 // const udpECNSupport indicates whether the platform supports setting 14 // the ECN (Explicit Congestion Notification) IP header bits. 15 // 16 // const udpInvalidLocalAddrIsError indicates whether sending a packet 17 // from an local address not associated with the system is an error. 18 // For example, assuming 127.0.0.2 is not a local address, does sending 19 // from it (using IP_PKTINFO or some other such feature) result in an error? 20 21 // unmapAddrPort returns a with any IPv4-mapped IPv6 address prefix removed. 22 func unmapAddrPort(a netip.AddrPort) netip.AddrPort { 23 if a.Addr().Is4In6() { 24 return netip.AddrPortFrom( 25 a.Addr().Unmap(), 26 a.Port(), 27 ) 28 } 29 return a 30 }