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.
 
 
 

56 lines
1.2 KiB

  1. // Copyright 2012 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 ipv4
  5. // TOS returns the type-of-service field value for outgoing packets.
  6. func (c *genericOpt) TOS() (int, error) {
  7. if !c.ok() {
  8. return 0, errInvalidConn
  9. }
  10. so, ok := sockOpts[ssoTOS]
  11. if !ok {
  12. return 0, errNotImplemented
  13. }
  14. return so.GetInt(c.Conn)
  15. }
  16. // SetTOS sets the type-of-service field value for future outgoing
  17. // packets.
  18. func (c *genericOpt) SetTOS(tos int) error {
  19. if !c.ok() {
  20. return errInvalidConn
  21. }
  22. so, ok := sockOpts[ssoTOS]
  23. if !ok {
  24. return errNotImplemented
  25. }
  26. return so.SetInt(c.Conn, tos)
  27. }
  28. // TTL returns the time-to-live field value for outgoing packets.
  29. func (c *genericOpt) TTL() (int, error) {
  30. if !c.ok() {
  31. return 0, errInvalidConn
  32. }
  33. so, ok := sockOpts[ssoTTL]
  34. if !ok {
  35. return 0, errNotImplemented
  36. }
  37. return so.GetInt(c.Conn)
  38. }
  39. // SetTTL sets the time-to-live field value for future outgoing
  40. // packets.
  41. func (c *genericOpt) SetTTL(ttl int) error {
  42. if !c.ok() {
  43. return errInvalidConn
  44. }
  45. so, ok := sockOpts[ssoTTL]
  46. if !ok {
  47. return errNotImplemented
  48. }
  49. return so.SetInt(c.Conn, ttl)
  50. }