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