mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-20 03:51:00 +00:00
65aaa607ab
Change made by: - running "gvt fetch" on each of the packages mentioned in Godeps/Godeps.json - `rm -rf Godeps` - tweaking the build scripts to not mention Godeps - tweaking the build scripts to test `./lib/...`, `./cmd/...` explicitly (to avoid testing vendor) - tweaking the build scripts to not juggle GOPATH for Godeps and instead set GO15VENDOREXPERIMENT. This also results in some updated packages at the same time I bet. Building with Go 1.3 and 1.4 still *works* but won't use our vendored dependencies - the user needs to have the actual packages in their GOPATH then, which they'll get with a normal "go get". Building with Go 1.6+ will get our vendored dependencies by default even when not using our build script, which is nice. By doing this we gain some freedom in that we can pick and choose manually what to include in vendor, as it's not based on just dependency analysis of our own code. This is also a risk as we might pick up dependencies we are unaware of, as the build may work locally with those packages present in GOPATH. On the other hand the build server will detect this as it has no packages in it's GOPATH beyond what is included in the repo. Recommended tool to manage dependencies is github.com/FiloSottile/gvt.
86 lines
3.0 KiB
Go
86 lines
3.0 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.
|
|
|
|
package ipv6
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"sync"
|
|
)
|
|
|
|
// Note that RFC 3542 obsoletes RFC 2292 but OS X Snow Leopard and the
|
|
// former still support RFC 2292 only. Please be aware that almost
|
|
// all protocol implementations prohibit using a combination of RFC
|
|
// 2292 and RFC 3542 for some practical reasons.
|
|
|
|
type rawOpt struct {
|
|
sync.RWMutex
|
|
cflags ControlFlags
|
|
}
|
|
|
|
func (c *rawOpt) set(f ControlFlags) { c.cflags |= f }
|
|
func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f }
|
|
func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 }
|
|
|
|
// A ControlFlags represents per packet basis IP-level socket option
|
|
// control flags.
|
|
type ControlFlags uint
|
|
|
|
const (
|
|
FlagTrafficClass ControlFlags = 1 << iota // pass the traffic class on the received packet
|
|
FlagHopLimit // pass the hop limit on the received packet
|
|
FlagSrc // pass the source address on the received packet
|
|
FlagDst // pass the destination address on the received packet
|
|
FlagInterface // pass the interface index on the received packet
|
|
FlagPathMTU // pass the path MTU on the received packet path
|
|
)
|
|
|
|
const flagPacketInfo = FlagDst | FlagInterface
|
|
|
|
// A ControlMessage represents per packet basis IP-level socket
|
|
// options.
|
|
type ControlMessage struct {
|
|
// Receiving socket options: SetControlMessage allows to
|
|
// receive the options from the protocol stack using ReadFrom
|
|
// method of PacketConn.
|
|
//
|
|
// Specifying socket options: ControlMessage for WriteTo
|
|
// method of PacketConn allows to send the options to the
|
|
// protocol stack.
|
|
//
|
|
TrafficClass int // traffic class, must be 1 <= value <= 255 when specifying
|
|
HopLimit int // hop limit, must be 1 <= value <= 255 when specifying
|
|
Src net.IP // source address, specifying only
|
|
Dst net.IP // destination address, receiving only
|
|
IfIndex int // interface index, must be 1 <= value when specifying
|
|
NextHop net.IP // next hop address, specifying only
|
|
MTU int // path MTU, receiving only
|
|
}
|
|
|
|
func (cm *ControlMessage) String() string {
|
|
if cm == nil {
|
|
return "<nil>"
|
|
}
|
|
return fmt.Sprintf("tclass=%#x hoplim=%d src=%v dst=%v ifindex=%d nexthop=%v mtu=%d", cm.TrafficClass, cm.HopLimit, cm.Src, cm.Dst, cm.IfIndex, cm.NextHop, cm.MTU)
|
|
}
|
|
|
|
// Ancillary data socket options
|
|
const (
|
|
ctlTrafficClass = iota // header field
|
|
ctlHopLimit // header field
|
|
ctlPacketInfo // inbound or outbound packet path
|
|
ctlNextHop // nexthop
|
|
ctlPathMTU // path mtu
|
|
ctlMax
|
|
)
|
|
|
|
// A ctlOpt represents a binding for ancillary data socket option.
|
|
type ctlOpt struct {
|
|
name int // option name, must be equal or greater than 1
|
|
length int // option length
|
|
marshal func([]byte, *ControlMessage) []byte
|
|
parse func(*ControlMessage, []byte)
|
|
}
|