You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 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. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package ipv6
  6. import "golang.org/x/net/internal/socket"
  7. func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error {
  8. opt.Lock()
  9. defer opt.Unlock()
  10. if so, ok := sockOpts[ssoReceiveTrafficClass]; ok && cf&FlagTrafficClass != 0 {
  11. if err := so.SetInt(c, boolint(on)); err != nil {
  12. return err
  13. }
  14. if on {
  15. opt.set(FlagTrafficClass)
  16. } else {
  17. opt.clear(FlagTrafficClass)
  18. }
  19. }
  20. if so, ok := sockOpts[ssoReceiveHopLimit]; ok && cf&FlagHopLimit != 0 {
  21. if err := so.SetInt(c, boolint(on)); err != nil {
  22. return err
  23. }
  24. if on {
  25. opt.set(FlagHopLimit)
  26. } else {
  27. opt.clear(FlagHopLimit)
  28. }
  29. }
  30. if so, ok := sockOpts[ssoReceivePacketInfo]; ok && cf&flagPacketInfo != 0 {
  31. if err := so.SetInt(c, boolint(on)); err != nil {
  32. return err
  33. }
  34. if on {
  35. opt.set(cf & flagPacketInfo)
  36. } else {
  37. opt.clear(cf & flagPacketInfo)
  38. }
  39. }
  40. if so, ok := sockOpts[ssoReceivePathMTU]; ok && cf&FlagPathMTU != 0 {
  41. if err := so.SetInt(c, boolint(on)); err != nil {
  42. return err
  43. }
  44. if on {
  45. opt.set(FlagPathMTU)
  46. } else {
  47. opt.clear(FlagPathMTU)
  48. }
  49. }
  50. return nil
  51. }