Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

60 linhas
1.1 KiB

  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 (
  6. "errors"
  7. "net"
  8. "runtime"
  9. )
  10. var (
  11. errInvalidConn = errors.New("invalid connection")
  12. errMissingAddress = errors.New("missing address")
  13. errHeaderTooShort = errors.New("header too short")
  14. errInvalidConnType = errors.New("invalid conn type")
  15. errNoSuchInterface = errors.New("no such interface")
  16. errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
  17. )
  18. func boolint(b bool) int {
  19. if b {
  20. return 1
  21. }
  22. return 0
  23. }
  24. func netAddrToIP16(a net.Addr) net.IP {
  25. switch v := a.(type) {
  26. case *net.UDPAddr:
  27. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  28. return ip
  29. }
  30. case *net.IPAddr:
  31. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  32. return ip
  33. }
  34. }
  35. return nil
  36. }
  37. func opAddr(a net.Addr) net.Addr {
  38. switch a.(type) {
  39. case *net.TCPAddr:
  40. if a == nil {
  41. return nil
  42. }
  43. case *net.UDPAddr:
  44. if a == nil {
  45. return nil
  46. }
  47. case *net.IPAddr:
  48. if a == nil {
  49. return nil
  50. }
  51. }
  52. return a
  53. }