helper.go 515 B

12345678910111213141516171819202122232425262728
  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. package ipv6
  5. import "net"
  6. func boolint(b bool) int {
  7. if b {
  8. return 1
  9. }
  10. return 0
  11. }
  12. func netAddrToIP16(a net.Addr) net.IP {
  13. switch v := a.(type) {
  14. case *net.UDPAddr:
  15. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  16. return ip
  17. }
  18. case *net.IPAddr:
  19. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  20. return ip
  21. }
  22. }
  23. return nil
  24. }