mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-20 11:55:18 +00:00
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
// +build darwin dragonfly freebsd linux netbsd openbsd windows
|
||
|
|
||
|
package ipv6
|
||
|
|
||
|
import "syscall"
|
||
|
|
||
|
// TrafficClass returns the traffic class field value for outgoing
|
||
|
// packets.
|
||
|
func (c *genericOpt) TrafficClass() (int, error) {
|
||
|
if !c.ok() {
|
||
|
return 0, syscall.EINVAL
|
||
|
}
|
||
|
fd, err := c.sysfd()
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
return getInt(fd, &sockOpts[ssoTrafficClass])
|
||
|
}
|
||
|
|
||
|
// SetTrafficClass sets the traffic class field value for future
|
||
|
// outgoing packets.
|
||
|
func (c *genericOpt) SetTrafficClass(tclass int) error {
|
||
|
if !c.ok() {
|
||
|
return syscall.EINVAL
|
||
|
}
|
||
|
fd, err := c.sysfd()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return setInt(fd, &sockOpts[ssoTrafficClass], tclass)
|
||
|
}
|
||
|
|
||
|
// HopLimit returns the hop limit field value for outgoing packets.
|
||
|
func (c *genericOpt) HopLimit() (int, error) {
|
||
|
if !c.ok() {
|
||
|
return 0, syscall.EINVAL
|
||
|
}
|
||
|
fd, err := c.sysfd()
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
return getInt(fd, &sockOpts[ssoHopLimit])
|
||
|
}
|
||
|
|
||
|
// SetHopLimit sets the hop limit field value for future outgoing
|
||
|
// packets.
|
||
|
func (c *genericOpt) SetHopLimit(hoplim int) error {
|
||
|
if !c.ok() {
|
||
|
return syscall.EINVAL
|
||
|
}
|
||
|
fd, err := c.sysfd()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return setInt(fd, &sockOpts[ssoHopLimit], hoplim)
|
||
|
}
|