github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/net/ipv6/helper.go (about) 1 // Copyright 2013 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 package ipv6 6 7 import ( 8 "errors" 9 "net" 10 ) 11 12 var ( 13 errMissingAddress = errors.New("missing address") 14 errHeaderTooShort = errors.New("header too short") 15 errInvalidConnType = errors.New("invalid conn type") 16 errOpNoSupport = errors.New("operation not supported") 17 errNoSuchInterface = errors.New("no such interface") 18 ) 19 20 func boolint(b bool) int { 21 if b { 22 return 1 23 } 24 return 0 25 } 26 27 func netAddrToIP16(a net.Addr) net.IP { 28 switch v := a.(type) { 29 case *net.UDPAddr: 30 if ip := v.IP.To16(); ip != nil && ip.To4() == nil { 31 return ip 32 } 33 case *net.IPAddr: 34 if ip := v.IP.To16(); ip != nil && ip.To4() == nil { 35 return ip 36 } 37 } 38 return nil 39 }