WIP: Save agent roles integration work before CHORUS rebrand
- Agent roles and coordination features - Chat API integration testing - New configuration and workspace management 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
vendor/github.com/mikioh/tcpinfo/.gitignore
generated
vendored
Normal file
24
vendor/github.com/mikioh/tcpinfo/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
16
vendor/github.com/mikioh/tcpinfo/.travis.yml
generated
vendored
Normal file
16
vendor/github.com/mikioh/tcpinfo/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
language: go
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
go:
|
||||
- 1.11.6
|
||||
- 1.12.1
|
||||
- tip
|
||||
|
||||
script:
|
||||
- go test -v -race
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
23
vendor/github.com/mikioh/tcpinfo/LICENSE
generated
vendored
Normal file
23
vendor/github.com/mikioh/tcpinfo/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2016, Mikio Hara
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
6
vendor/github.com/mikioh/tcpinfo/README.md
generated
vendored
Normal file
6
vendor/github.com/mikioh/tcpinfo/README.md
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Package tcpinfo implements encoding and decoding of TCP-level socket options regarding connection information.
|
||||
|
||||
[](https://godoc.org/github.com/mikioh/tcpinfo)
|
||||
[](https://travis-ci.org/mikioh/tcpinfo)
|
||||
[](https://ci.appveyor.com/project/mikioh/tcpinfo)
|
||||
[](https://goreportcard.com/report/github.com/mikioh/tcpinfo)
|
||||
18
vendor/github.com/mikioh/tcpinfo/appveyor.yml
generated
vendored
Normal file
18
vendor/github.com/mikioh/tcpinfo/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
version: "{build}"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
|
||||
install:
|
||||
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
|
||||
- mkdir c:\gopath
|
||||
- go get github.com/mikioh/tcp
|
||||
- go get github.com/mikioh/tcpopt
|
||||
- go get github.com/mikioh/tcpinfo
|
||||
|
||||
build_script:
|
||||
- go test -v -race
|
||||
20
vendor/github.com/mikioh/tcpinfo/doc.go
generated
vendored
Normal file
20
vendor/github.com/mikioh/tcpinfo/doc.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package tcpinfo implements encoding and decoding of TCP-level
|
||||
// socket options regarding connection information.
|
||||
//
|
||||
// The Transmission Control Protocol (TCP) is defined in RFC 793.
|
||||
// TCP Selective Acknowledgment Options is defined in RFC 2018.
|
||||
// Management Information Base for the Transmission Control Protocol
|
||||
// (TCP) is defined in RFC 4022.
|
||||
// TCP Congestion Control is defined in RFC 5681.
|
||||
// Computing TCP's Retransmission Timer is described in RFC 6298.
|
||||
// TCP Options and Maximum Segment Size (MSS) is defined in RFC 6691.
|
||||
// Shared Use of Experimental TCP Options is defined in RFC 6994.
|
||||
// TCP Extensions for High Performance is defined in RFC 7323.
|
||||
//
|
||||
// NOTE: Older Linux kernels may not support extended TCP statistics
|
||||
// described in RFC 4898.
|
||||
package tcpinfo
|
||||
157
vendor/github.com/mikioh/tcpinfo/option.go
generated
vendored
Normal file
157
vendor/github.com/mikioh/tcpinfo/option.go
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/mikioh/tcpopt"
|
||||
)
|
||||
|
||||
var (
|
||||
_ json.Marshaler = &Info{}
|
||||
_ tcpopt.Option = &Info{}
|
||||
)
|
||||
|
||||
// An Info represents connection information.
|
||||
//
|
||||
// Only supported on Darwin, FreeBSD, Linux and NetBSD.
|
||||
type Info struct {
|
||||
State State `json:"state"` // connection state
|
||||
Options []Option `json:"opts,omitempty"` // requesting options
|
||||
PeerOptions []Option `json:"peer_opts,omitempty"` // options requested from peer
|
||||
SenderMSS MaxSegSize `json:"snd_mss"` // maximum segment size for sender in bytes
|
||||
ReceiverMSS MaxSegSize `json:"rcv_mss"` // maximum segment size for receiver in bytes
|
||||
RTT time.Duration `json:"rtt"` // round-trip time
|
||||
RTTVar time.Duration `json:"rttvar"` // round-trip time variation
|
||||
RTO time.Duration `json:"rto"` // retransmission timeout
|
||||
ATO time.Duration `json:"ato"` // delayed acknowledgement timeout [Linux only]
|
||||
LastDataSent time.Duration `json:"last_data_sent"` // since last data sent [Linux only]
|
||||
LastDataReceived time.Duration `json:"last_data_rcvd"` // since last data received [FreeBSD and Linux]
|
||||
LastAckReceived time.Duration `json:"last_ack_rcvd"` // since last ack received [Linux only]
|
||||
FlowControl *FlowControl `json:"flow_ctl,omitempty"` // flow control information
|
||||
CongestionControl *CongestionControl `json:"cong_ctl,omitempty"` // congestion control information
|
||||
Sys *SysInfo `json:"sys,omitempty"` // platform-specific information
|
||||
}
|
||||
|
||||
// A FlowControl represents flow control information.
|
||||
type FlowControl struct {
|
||||
ReceiverWindow uint `json:"rcv_wnd"` // advertised receiver window in bytes
|
||||
}
|
||||
|
||||
// A CongestionControl represents congestion control information.
|
||||
type CongestionControl struct {
|
||||
SenderSSThreshold uint `json:"snd_ssthresh"` // slow start threshold for sender in bytes or # of segments
|
||||
ReceiverSSThreshold uint `json:"rcv_ssthresh"` // slow start threshold for receiver in bytes [Linux only]
|
||||
SenderWindowBytes uint `json:"snd_cwnd_bytes"` // congestion window for sender in bytes [Darwin and FreeBSD]
|
||||
SenderWindowSegs uint `json:"snd_cwnd_segs"` // congestion window for sender in # of segments [Linux and NetBSD]
|
||||
}
|
||||
|
||||
// Level implements the Level method of tcpopt.Option interface.
|
||||
func (i *Info) Level() int { return options[soInfo].level }
|
||||
|
||||
// Name implements the Name method of tcpopt.Option interface.
|
||||
func (i *Info) Name() int { return options[soInfo].name }
|
||||
|
||||
// MarshalJSON implements the MarshalJSON method of json.Marshaler
|
||||
// interface.
|
||||
func (i *Info) MarshalJSON() ([]byte, error) {
|
||||
raw := make(map[string]interface{})
|
||||
raw["state"] = i.State.String()
|
||||
if len(i.Options) > 0 {
|
||||
opts := make(map[string]interface{})
|
||||
for _, opt := range i.Options {
|
||||
opts[opt.Kind().String()] = opt
|
||||
}
|
||||
raw["opts"] = opts
|
||||
}
|
||||
if len(i.PeerOptions) > 0 {
|
||||
opts := make(map[string]interface{})
|
||||
for _, opt := range i.PeerOptions {
|
||||
opts[opt.Kind().String()] = opt
|
||||
}
|
||||
raw["peer_opts"] = opts
|
||||
}
|
||||
raw["snd_mss"] = i.SenderMSS
|
||||
raw["rcv_mss"] = i.ReceiverMSS
|
||||
raw["rtt"] = i.RTT
|
||||
raw["rttvar"] = i.RTTVar
|
||||
raw["rto"] = i.RTO
|
||||
raw["ato"] = i.ATO
|
||||
raw["last_data_sent"] = i.LastDataSent
|
||||
raw["last_data_rcvd"] = i.LastDataReceived
|
||||
raw["last_ack_rcvd"] = i.LastAckReceived
|
||||
if i.FlowControl != nil {
|
||||
raw["flow_ctl"] = i.FlowControl
|
||||
}
|
||||
if i.CongestionControl != nil {
|
||||
raw["cong_ctl"] = i.CongestionControl
|
||||
}
|
||||
if i.Sys != nil {
|
||||
raw["sys"] = i.Sys
|
||||
}
|
||||
return json.Marshal(&raw)
|
||||
}
|
||||
|
||||
// A CCInfo represents raw information of congestion control
|
||||
// algorithm.
|
||||
//
|
||||
// Only supported on Linux.
|
||||
type CCInfo struct {
|
||||
Raw []byte `json:"raw,omitempty"`
|
||||
}
|
||||
|
||||
// Level implements the Level method of tcpopt.Option interface.
|
||||
func (cci *CCInfo) Level() int { return options[soCCInfo].level }
|
||||
|
||||
// Name implements the Name method of tcpopt.Option interface.
|
||||
func (cci *CCInfo) Name() int { return options[soCCInfo].name }
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (cci *CCInfo) Marshal() ([]byte, error) { return cci.Raw, nil }
|
||||
|
||||
func parseCCInfo(b []byte) (tcpopt.Option, error) { return &CCInfo{Raw: b}, nil }
|
||||
|
||||
// A CCAlgorithm represents a name of congestion control algorithm.
|
||||
//
|
||||
// Only supported on Linux.
|
||||
type CCAlgorithm string
|
||||
|
||||
// Level implements the Level method of tcpopt.Option interface.
|
||||
func (cca CCAlgorithm) Level() int { return options[soCCAlgo].level }
|
||||
|
||||
// Name implements the Name method of tcpopt.Option interface.
|
||||
func (cca CCAlgorithm) Name() int { return options[soCCAlgo].name }
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (cca CCAlgorithm) Marshal() ([]byte, error) {
|
||||
if cca == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return []byte(cca), nil
|
||||
}
|
||||
|
||||
func parseCCAlgorithm(b []byte) (tcpopt.Option, error) { return CCAlgorithm(b), nil }
|
||||
|
||||
// A CCAlgorithmInfo represents congestion control algorithm
|
||||
// information.
|
||||
//
|
||||
// Only supported on Linux.
|
||||
type CCAlgorithmInfo interface {
|
||||
Algorithm() string
|
||||
}
|
||||
|
||||
// ParseCCAlgorithmInfo parses congestion control algorithm
|
||||
// information.
|
||||
//
|
||||
// Only supported on Linux.
|
||||
func ParseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
|
||||
ccai, err := parseCCAlgorithmInfo(name, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ccai, nil
|
||||
}
|
||||
34
vendor/github.com/mikioh/tcpinfo/sys.go
generated
vendored
Normal file
34
vendor/github.com/mikioh/tcpinfo/sys.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import "github.com/mikioh/tcpopt"
|
||||
|
||||
func init() {
|
||||
for _, o := range options {
|
||||
if o.name == 0 || o.parseFn == nil {
|
||||
continue
|
||||
}
|
||||
tcpopt.Register(o.level, o.name, o.parseFn)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
ianaProtocolTCP = 0x6
|
||||
)
|
||||
|
||||
const (
|
||||
soInfo = iota
|
||||
soCCInfo
|
||||
soCCAlgo
|
||||
soMax
|
||||
)
|
||||
|
||||
// An option represents a binding for socket option.
|
||||
type option struct {
|
||||
level int // option level
|
||||
name int // option name, must be equal or greater than 1
|
||||
parseFn func([]byte) (tcpopt.Option, error)
|
||||
}
|
||||
96
vendor/github.com/mikioh/tcpinfo/sys_bsd.go
generated
vendored
Normal file
96
vendor/github.com/mikioh/tcpinfo/sys_bsd.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build freebsd netbsd
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/mikioh/tcpopt"
|
||||
)
|
||||
|
||||
var options = [soMax]option{
|
||||
soInfo: {ianaProtocolTCP, sysTCP_INFO, parseInfo},
|
||||
}
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (i *Info) Marshal() ([]byte, error) { return (*[sizeofTCPInfo]byte)(unsafe.Pointer(i))[:], nil }
|
||||
|
||||
// A SysInfo represents platform-specific information.
|
||||
type SysInfo struct {
|
||||
SenderWindowBytes uint `json:"snd_wnd_bytes"` // advertised sender window in bytes [FreeBSD]
|
||||
SenderWindowSegs uint `json:"snd_wnd_segs"` // advertised sender window in # of segments [NetBSD]
|
||||
NextEgressSeq uint `json:"egress_seq"` // next egress seq. number
|
||||
NextIngressSeq uint `json:"ingress_seq"` // next ingress seq. number
|
||||
RetransSegs uint `json:"retrans_segs"` // # of retransmit segments sent
|
||||
OutOfOrderSegs uint `json:"ooo_segs"` // # of out-of-order segments received
|
||||
ZeroWindowUpdates uint `json:"zerownd_updates"` // # of zero-window updates sent
|
||||
Offloading bool `json:"offloading"` // TCP offload processing
|
||||
}
|
||||
|
||||
var sysStates = [11]State{Closed, Listen, SynSent, SynReceived, Established, CloseWait, FinWait1, Closing, LastAck, FinWait2, TimeWait}
|
||||
|
||||
func parseInfo(b []byte) (tcpopt.Option, error) {
|
||||
if len(b) < sizeofTCPInfo {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
ti := (*tcpInfo)(unsafe.Pointer(&b[0]))
|
||||
i := &Info{State: sysStates[ti.State]}
|
||||
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
|
||||
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
|
||||
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_SACK != 0 {
|
||||
i.Options = append(i.Options, SACKPermitted(true))
|
||||
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
|
||||
i.Options = append(i.Options, Timestamps(true))
|
||||
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
|
||||
}
|
||||
i.SenderMSS = MaxSegSize(ti.Snd_mss)
|
||||
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
|
||||
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
|
||||
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
|
||||
i.RTO = time.Duration(ti.Rto) * time.Microsecond
|
||||
i.ATO = time.Duration(ti.X__tcpi_ato) * time.Microsecond
|
||||
i.LastDataSent = time.Duration(ti.X__tcpi_last_data_sent) * time.Microsecond
|
||||
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Microsecond
|
||||
i.LastAckReceived = time.Duration(ti.X__tcpi_last_ack_recv) * time.Microsecond
|
||||
i.FlowControl = &FlowControl{
|
||||
ReceiverWindow: uint(ti.Rcv_space),
|
||||
}
|
||||
i.CongestionControl = &CongestionControl{
|
||||
SenderSSThreshold: uint(ti.Snd_ssthresh),
|
||||
ReceiverSSThreshold: uint(ti.X__tcpi_rcv_ssthresh),
|
||||
}
|
||||
i.Sys = &SysInfo{
|
||||
NextEgressSeq: uint(ti.Snd_nxt),
|
||||
NextIngressSeq: uint(ti.Rcv_nxt),
|
||||
RetransSegs: uint(ti.Snd_rexmitpack),
|
||||
OutOfOrderSegs: uint(ti.Rcv_ooopack),
|
||||
ZeroWindowUpdates: uint(ti.Snd_zerowin),
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_TOE != 0 {
|
||||
i.Sys.Offloading = true
|
||||
}
|
||||
switch runtime.GOOS {
|
||||
case "freebsd":
|
||||
i.CongestionControl.SenderWindowBytes = uint(ti.Snd_cwnd)
|
||||
i.Sys.SenderWindowBytes = uint(ti.Snd_wnd)
|
||||
case "netbsd":
|
||||
i.CongestionControl.SenderWindowSegs = uint(ti.Snd_cwnd)
|
||||
i.Sys.SenderWindowSegs = uint(ti.Snd_wnd)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
|
||||
return nil, errors.New("operation not supported")
|
||||
}
|
||||
114
vendor/github.com/mikioh/tcpinfo/sys_darwin.go
generated
vendored
Normal file
114
vendor/github.com/mikioh/tcpinfo/sys_darwin.go
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/mikioh/tcpopt"
|
||||
)
|
||||
|
||||
var options = [soMax]option{
|
||||
soInfo: {ianaProtocolTCP, sysTCP_CONNECTION_INFO, parseInfo},
|
||||
}
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (i *Info) Marshal() ([]byte, error) {
|
||||
return (*[sizeofTCPConnectionInfo]byte)(unsafe.Pointer(i))[:], nil
|
||||
}
|
||||
|
||||
type SysFlags uint
|
||||
|
||||
func (f SysFlags) String() string {
|
||||
s := ""
|
||||
for i, name := range []string{
|
||||
"loss recovery",
|
||||
"reordering detected",
|
||||
} {
|
||||
if f&(1<<uint(i)) != 0 {
|
||||
if s != "" {
|
||||
s += "|"
|
||||
}
|
||||
s += name
|
||||
}
|
||||
}
|
||||
if s == "" {
|
||||
s = "0"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// A SysInfo represents platform-specific information.
|
||||
type SysInfo struct {
|
||||
Flags SysFlags `json:"flags"` // flags
|
||||
SenderWindow uint `json:"snd_wnd"` // advertised sender window in bytes
|
||||
SenderInUse uint `json:"snd_inuse"` // bytes in send buffer including inflight data
|
||||
SRTT time.Duration `json:"srtt"` // smoothed round-trip time
|
||||
SegsSent uint64 `json:"segs_sent"` // # of segements sent
|
||||
BytesSent uint64 `json:"bytes_sent"` // # of bytes sent
|
||||
RetransBytes uint64 `json:"retrans_bytes"` // # of retransmitted bytes
|
||||
SegsReceived uint64 `json:"segs_rcvd"` // # of segments received
|
||||
BytesReceived uint64 `json:"bytes_rcvd"` // # of bytes received
|
||||
OutOfOrderBytesReceived uint64 `json:"ooo_bytes_rcvd"` // # of our-of-order bytes received
|
||||
RetransSegs uint64 `json:"retrans_segs"` // # of retransmitted segments
|
||||
}
|
||||
|
||||
var sysStates = [11]State{Closed, Listen, SynSent, SynReceived, Established, CloseWait, FinWait1, Closing, LastAck, FinWait2, TimeWait}
|
||||
|
||||
const sizeofTCPConnectionInfoV15 = 0x68
|
||||
|
||||
func parseInfo(b []byte) (tcpopt.Option, error) {
|
||||
if len(b) < sizeofTCPConnectionInfoV15 {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
tci := (*tcpConnectionInfo)(unsafe.Pointer(&b[0]))
|
||||
i := &Info{State: sysStates[tci.State]}
|
||||
if tci.Options&sysTCPCI_OPT_WSCALE != 0 {
|
||||
i.Options = append(i.Options, WindowScale(tci.Snd_wscale))
|
||||
i.PeerOptions = append(i.PeerOptions, WindowScale(tci.Rcv_wscale))
|
||||
}
|
||||
if tci.Options&sysTCPCI_OPT_SACK != 0 {
|
||||
i.Options = append(i.Options, SACKPermitted(true))
|
||||
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
|
||||
}
|
||||
if tci.Options&sysTCPCI_OPT_TIMESTAMPS != 0 {
|
||||
i.Options = append(i.Options, Timestamps(true))
|
||||
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
|
||||
}
|
||||
i.SenderMSS = MaxSegSize(tci.Maxseg)
|
||||
i.ReceiverMSS = MaxSegSize(tci.Maxseg)
|
||||
i.RTT = time.Duration(tci.Rttcur) * time.Millisecond
|
||||
i.RTTVar = time.Duration(tci.Rttvar) * time.Millisecond
|
||||
i.RTO = time.Duration(tci.Rto) * time.Millisecond
|
||||
i.FlowControl = &FlowControl{
|
||||
ReceiverWindow: uint(tci.Rcv_wnd),
|
||||
}
|
||||
i.CongestionControl = &CongestionControl{
|
||||
SenderSSThreshold: uint(tci.Snd_ssthresh),
|
||||
SenderWindowBytes: uint(tci.Snd_cwnd),
|
||||
}
|
||||
i.Sys = &SysInfo{
|
||||
Flags: SysFlags(tci.Flags),
|
||||
SenderWindow: uint(tci.Snd_wnd),
|
||||
SenderInUse: uint(tci.Snd_sbbytes),
|
||||
SRTT: time.Duration(tci.Srtt) * time.Millisecond,
|
||||
SegsSent: uint64(tci.Txpackets),
|
||||
BytesSent: uint64(tci.Txbytes),
|
||||
RetransBytes: uint64(tci.Txretransmitbytes),
|
||||
SegsReceived: uint64(tci.Rxpackets),
|
||||
BytesReceived: uint64(tci.Rxbytes),
|
||||
OutOfOrderBytesReceived: uint64(tci.Rxoutoforderbytes),
|
||||
}
|
||||
if len(b) > sizeofTCPConnectionInfoV15 {
|
||||
i.Sys.RetransSegs = uint64(tci.Txretransmitpackets)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
|
||||
return nil, errors.New("operation not supported")
|
||||
}
|
||||
331
vendor/github.com/mikioh/tcpinfo/sys_linux.go
generated
vendored
Normal file
331
vendor/github.com/mikioh/tcpinfo/sys_linux.go
generated
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/mikioh/tcpopt"
|
||||
)
|
||||
|
||||
var options = [soMax]option{
|
||||
soInfo: {ianaProtocolTCP, sysTCP_INFO, parseInfo},
|
||||
soCCInfo: {ianaProtocolTCP, sysTCP_CC_INFO, parseCCInfo},
|
||||
soCCAlgo: {ianaProtocolTCP, sysTCP_CONGESTION, parseCCAlgorithm},
|
||||
}
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (i *Info) Marshal() ([]byte, error) { return (*[sizeofTCPInfo]byte)(unsafe.Pointer(i))[:], nil }
|
||||
|
||||
// A CAState represents a state of congestion avoidance.
|
||||
type CAState int
|
||||
|
||||
var caStates = map[CAState]string{
|
||||
CAOpen: "open",
|
||||
CADisorder: "disorder",
|
||||
CACWR: "congestion window reduced",
|
||||
CARecovery: "recovery",
|
||||
CALoss: "loss",
|
||||
}
|
||||
|
||||
func (st CAState) String() string {
|
||||
s, ok := caStates[st]
|
||||
if !ok {
|
||||
return "<nil>"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// A SysInfo represents platform-specific information.
|
||||
type SysInfo struct {
|
||||
PathMTU uint `json:"path_mtu"` // path maximum transmission unit
|
||||
AdvertisedMSS MaxSegSize `json:"adv_mss"` // advertised maximum segment size
|
||||
CAState CAState `json:"ca_state"` // state of congestion avoidance
|
||||
Retransmissions uint `json:"rexmits"` // # of retranmissions on timeout invoked
|
||||
Backoffs uint `json:"backoffs"` // # of times retransmission backoff timer invoked
|
||||
WindowOrKeepAliveProbes uint `json:"wnd_ka_probes"` // # of window or keep alive probes sent
|
||||
UnackedSegs uint `json:"unacked_segs"` // # of unack'd segments
|
||||
SackedSegs uint `json:"sacked_segs"` // # of sack'd segments
|
||||
LostSegs uint `json:"lost_segs"` // # of lost segments
|
||||
RetransSegs uint `json:"retrans_segs"` // # of retransmitting segments in transmission queue
|
||||
ForwardAckSegs uint `json:"fack_segs"` // # of forward ack segments in transmission queue
|
||||
ReorderedSegs uint `json:"reord_segs"` // # of reordered segments allowed
|
||||
ReceiverRTT time.Duration `json:"rcv_rtt"` // current RTT for receiver
|
||||
TotalRetransSegs uint `json:"total_retrans_segs"` // # of retransmitted segments
|
||||
PacingRate uint64 `json:"pacing_rate"` // pacing rate
|
||||
ThruBytesAcked uint64 `json:"thru_bytes_acked"` // # of bytes for which cumulative acknowledgments have been received
|
||||
ThruBytesReceived uint64 `json:"thru_bytes_rcvd"` // # of bytes for which cumulative acknowledgments have been sent
|
||||
SegsOut uint `json:"segs_out"` // # of segments sent
|
||||
SegsIn uint `json:"segs_in"` // # of segments received
|
||||
NotSentBytes uint `json:"not_sent_bytes"` // # of bytes not sent yet
|
||||
MinRTT time.Duration `json:"min_rtt"` // current measured minimum RTT; zero means not available
|
||||
DataSegsOut uint `json:"data_segs_out"` // # of segments sent containing a positive length data segment
|
||||
DataSegsIn uint `json:"data_segs_in"` // # of segments received containing a positive length data segment
|
||||
}
|
||||
|
||||
var sysStates = [12]State{Unknown, Established, SynSent, SynReceived, FinWait1, FinWait2, TimeWait, Closed, CloseWait, LastAck, Listen, Closing}
|
||||
|
||||
const (
|
||||
sizeofTCPInfoV4_9 = 0xa0
|
||||
sizeofTCPInfoV3_19 = 0x78
|
||||
sizeofTCPInfoV2_6_10 = 0x57
|
||||
)
|
||||
|
||||
func parseInfo(b []byte) (tcpopt.Option, error) {
|
||||
if len(b) < sizeofTCPInfoV4_9 {
|
||||
return parseInfo3_19(b)
|
||||
}
|
||||
ti := (*tcpInfo)(unsafe.Pointer(&b[0]))
|
||||
i := &Info{State: sysStates[ti.State]}
|
||||
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
|
||||
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
|
||||
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_SACK != 0 {
|
||||
i.Options = append(i.Options, SACKPermitted(true))
|
||||
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
|
||||
i.Options = append(i.Options, Timestamps(true))
|
||||
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
|
||||
}
|
||||
i.SenderMSS = MaxSegSize(ti.Snd_mss)
|
||||
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
|
||||
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
|
||||
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
|
||||
i.RTO = time.Duration(ti.Rto) * time.Microsecond
|
||||
i.ATO = time.Duration(ti.Ato) * time.Microsecond
|
||||
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
|
||||
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
|
||||
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
|
||||
i.FlowControl = &FlowControl{
|
||||
ReceiverWindow: uint(ti.Rcv_space),
|
||||
}
|
||||
i.CongestionControl = &CongestionControl{
|
||||
SenderSSThreshold: uint(ti.Snd_ssthresh),
|
||||
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
|
||||
SenderWindowSegs: uint(ti.Snd_cwnd),
|
||||
}
|
||||
i.Sys = &SysInfo{
|
||||
PathMTU: uint(ti.Pmtu),
|
||||
AdvertisedMSS: MaxSegSize(ti.Advmss),
|
||||
CAState: CAState(ti.Ca_state),
|
||||
Retransmissions: uint(ti.Retransmits),
|
||||
Backoffs: uint(ti.Backoff),
|
||||
WindowOrKeepAliveProbes: uint(ti.Probes),
|
||||
UnackedSegs: uint(ti.Unacked),
|
||||
SackedSegs: uint(ti.Sacked),
|
||||
LostSegs: uint(ti.Lost),
|
||||
RetransSegs: uint(ti.Retrans),
|
||||
ForwardAckSegs: uint(ti.Fackets),
|
||||
ReorderedSegs: uint(ti.Reordering),
|
||||
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
|
||||
TotalRetransSegs: uint(ti.Total_retrans),
|
||||
PacingRate: uint64(ti.Pacing_rate),
|
||||
ThruBytesAcked: uint64(ti.Bytes_acked),
|
||||
ThruBytesReceived: uint64(ti.Bytes_received),
|
||||
SegsIn: uint(ti.Segs_in),
|
||||
SegsOut: uint(ti.Segs_out),
|
||||
NotSentBytes: uint(ti.Notsent_bytes),
|
||||
MinRTT: time.Duration(ti.Min_rtt) * time.Microsecond,
|
||||
DataSegsIn: uint(ti.Data_segs_in),
|
||||
DataSegsOut: uint(ti.Data_segs_out),
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func parseInfo3_19(b []byte) (tcpopt.Option, error) {
|
||||
if len(b) < sizeofTCPInfoV3_19 {
|
||||
return parseInfo2_6_10(b)
|
||||
}
|
||||
ti := (*tcpInfo3_19)(unsafe.Pointer(&b[0]))
|
||||
i := &Info{State: sysStates[ti.State]}
|
||||
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
|
||||
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
|
||||
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_SACK != 0 {
|
||||
i.Options = append(i.Options, SACKPermitted(true))
|
||||
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
|
||||
i.Options = append(i.Options, Timestamps(true))
|
||||
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
|
||||
}
|
||||
i.SenderMSS = MaxSegSize(ti.Snd_mss)
|
||||
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
|
||||
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
|
||||
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
|
||||
i.RTO = time.Duration(ti.Rto) * time.Microsecond
|
||||
i.ATO = time.Duration(ti.Ato) * time.Microsecond
|
||||
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
|
||||
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
|
||||
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
|
||||
i.FlowControl = &FlowControl{
|
||||
ReceiverWindow: uint(ti.Rcv_space),
|
||||
}
|
||||
i.CongestionControl = &CongestionControl{
|
||||
SenderSSThreshold: uint(ti.Snd_ssthresh),
|
||||
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
|
||||
SenderWindowSegs: uint(ti.Snd_cwnd),
|
||||
}
|
||||
i.Sys = &SysInfo{
|
||||
PathMTU: uint(ti.Pmtu),
|
||||
AdvertisedMSS: MaxSegSize(ti.Advmss),
|
||||
CAState: CAState(ti.Ca_state),
|
||||
Retransmissions: uint(ti.Retransmits),
|
||||
Backoffs: uint(ti.Backoff),
|
||||
WindowOrKeepAliveProbes: uint(ti.Probes),
|
||||
UnackedSegs: uint(ti.Unacked),
|
||||
SackedSegs: uint(ti.Sacked),
|
||||
LostSegs: uint(ti.Lost),
|
||||
RetransSegs: uint(ti.Retrans),
|
||||
ForwardAckSegs: uint(ti.Fackets),
|
||||
ReorderedSegs: uint(ti.Reordering),
|
||||
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
|
||||
TotalRetransSegs: uint(ti.Total_retrans),
|
||||
PacingRate: uint64(ti.Pacing_rate),
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func parseInfo2_6_10(b []byte) (tcpopt.Option, error) {
|
||||
if len(b) < sizeofTCPInfoV2_6_10 {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
ti := (*tcpInfo2_6_10)(unsafe.Pointer(&b[0]))
|
||||
i := &Info{State: sysStates[ti.State]}
|
||||
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
|
||||
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
|
||||
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_SACK != 0 {
|
||||
i.Options = append(i.Options, SACKPermitted(true))
|
||||
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
|
||||
}
|
||||
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
|
||||
i.Options = append(i.Options, Timestamps(true))
|
||||
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
|
||||
}
|
||||
i.SenderMSS = MaxSegSize(ti.Snd_mss)
|
||||
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
|
||||
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
|
||||
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
|
||||
i.RTO = time.Duration(ti.Rto) * time.Microsecond
|
||||
i.ATO = time.Duration(ti.Ato) * time.Microsecond
|
||||
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
|
||||
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
|
||||
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
|
||||
i.FlowControl = &FlowControl{
|
||||
ReceiverWindow: uint(ti.Rcv_space),
|
||||
}
|
||||
i.CongestionControl = &CongestionControl{
|
||||
SenderSSThreshold: uint(ti.Snd_ssthresh),
|
||||
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
|
||||
SenderWindowSegs: uint(ti.Snd_cwnd),
|
||||
}
|
||||
i.Sys = &SysInfo{
|
||||
PathMTU: uint(ti.Pmtu),
|
||||
AdvertisedMSS: MaxSegSize(ti.Advmss),
|
||||
CAState: CAState(ti.Ca_state),
|
||||
Retransmissions: uint(ti.Retransmits),
|
||||
Backoffs: uint(ti.Backoff),
|
||||
WindowOrKeepAliveProbes: uint(ti.Probes),
|
||||
UnackedSegs: uint(ti.Unacked),
|
||||
SackedSegs: uint(ti.Sacked),
|
||||
LostSegs: uint(ti.Lost),
|
||||
RetransSegs: uint(ti.Retrans),
|
||||
ForwardAckSegs: uint(ti.Fackets),
|
||||
ReorderedSegs: uint(ti.Reordering),
|
||||
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
|
||||
TotalRetransSegs: uint(ti.Total_retrans),
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// A VegasInfo represents Vegas congestion control information.
|
||||
type VegasInfo struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
RoundTrips uint `json:"rnd_trips"` // # of round-trips
|
||||
RTT time.Duration `json:"rtt"` // round-trip time
|
||||
MinRTT time.Duration `json:"min_rtt"` // minimum round-trip time
|
||||
}
|
||||
|
||||
// Algorithm implements the Algorithm method of CCAlgorithmInfo
|
||||
// interface.
|
||||
func (vi *VegasInfo) Algorithm() string { return "vegas" }
|
||||
|
||||
// A CEState represents a state of ECN congestion encountered (CE)
|
||||
// codepoint.
|
||||
type CEState int
|
||||
|
||||
// A DCTCPInfo represents Datacenter TCP congestion control
|
||||
// information.
|
||||
type DCTCPInfo struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
CEState CEState `json:"ce_state"` // state of ECN CE codepoint
|
||||
Alpha uint `json:"alpha"` // fraction of bytes sent
|
||||
ECNAckedBytes uint `json:"ecn_acked"` // # of acked bytes with ECN
|
||||
TotalAckedBytes uint `json:"total_acked"` // total # of acked bytes
|
||||
}
|
||||
|
||||
// Algorithm implements the Algorithm method of CCAlgorithmInfo
|
||||
// interface.
|
||||
func (di *DCTCPInfo) Algorithm() string { return "dctcp" }
|
||||
|
||||
// A BBRInfo represents Bottleneck Bandwidth and Round-trip
|
||||
// propagation time-based congestion control information.
|
||||
type BBRInfo struct {
|
||||
MaxBW uint64 `json:"max_bw"` // maximum-filtered bandwidth in bps
|
||||
MinRTT time.Duration `json:"min_rtt"` // minimum-filtered round-trip time
|
||||
PacingGain uint `json:"pacing_gain"` // pacing gain shifted left 8 bits
|
||||
CongWindowGain uint `json:"cwnd_gain"` // congestion window gain shifted left 8 bits
|
||||
}
|
||||
|
||||
// Algorithm implements the Algorithm method of CCAlgorithmInfo
|
||||
// interface.
|
||||
func (bi *BBRInfo) Algorithm() string { return "bbr" }
|
||||
|
||||
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
|
||||
if strings.HasPrefix(name, "dctcp") {
|
||||
if len(b) < sizeofTCPDCTCPInfo {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
sdi := (*tcpDCTCPInfo)(unsafe.Pointer(&b[0]))
|
||||
di := &DCTCPInfo{Alpha: uint(sdi.Alpha)}
|
||||
if sdi.Enabled != 0 {
|
||||
di.Enabled = true
|
||||
}
|
||||
return di, nil
|
||||
}
|
||||
if strings.HasPrefix(name, "bbr") {
|
||||
if len(b) < sizeofTCPBBRInfo {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
sbi := (*tcpBBRInfo)(unsafe.Pointer(&b[0]))
|
||||
return &BBRInfo{
|
||||
MaxBW: uint64(sbi.Bw_hi)<<32 | uint64(sbi.Bw_lo),
|
||||
MinRTT: time.Duration(sbi.Min_rtt) * time.Microsecond,
|
||||
PacingGain: uint(sbi.Pacing_gain),
|
||||
CongWindowGain: uint(sbi.Cwnd_gain),
|
||||
}, nil
|
||||
}
|
||||
if len(b) < sizeofTCPVegasInfo {
|
||||
return nil, errors.New("short buffer")
|
||||
}
|
||||
svi := (*tcpVegasInfo)(unsafe.Pointer(&b[0]))
|
||||
vi := &VegasInfo{
|
||||
RoundTrips: uint(svi.Rttcnt),
|
||||
RTT: time.Duration(svi.Rtt) * time.Microsecond,
|
||||
MinRTT: time.Duration(svi.Minrtt) * time.Microsecond,
|
||||
}
|
||||
if svi.Enabled != 0 {
|
||||
vi.Enabled = true
|
||||
}
|
||||
return vi, nil
|
||||
}
|
||||
31
vendor/github.com/mikioh/tcpinfo/sys_stub.go
generated
vendored
Normal file
31
vendor/github.com/mikioh/tcpinfo/sys_stub.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2016 Mikio Hara. 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,!freebsd,!linux,!netbsd
|
||||
|
||||
package tcpinfo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/mikioh/tcpopt"
|
||||
)
|
||||
|
||||
var options [soMax]option
|
||||
|
||||
// Marshal implements the Marshal method of tcpopt.Option interface.
|
||||
func (i *Info) Marshal() ([]byte, error) {
|
||||
return nil, errors.New("operation not supported")
|
||||
}
|
||||
|
||||
// A SysInfo represents platform-specific information.
|
||||
type SysInfo struct{}
|
||||
|
||||
func parseInfo(b []byte) (tcpopt.Option, error) {
|
||||
return nil, errors.New("operation not supported")
|
||||
}
|
||||
|
||||
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
|
||||
return nil, errors.New("operation not supported")
|
||||
}
|
||||
101
vendor/github.com/mikioh/tcpinfo/tcp.go
generated
vendored
Normal file
101
vendor/github.com/mikioh/tcpinfo/tcp.go
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright 2016 Mikio Hara. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tcpinfo
|
||||
|
||||
// A State represents a state of connection.
|
||||
type State int
|
||||
|
||||
const (
|
||||
Unknown State = iota
|
||||
Closed
|
||||
Listen
|
||||
SynSent
|
||||
SynReceived
|
||||
Established
|
||||
FinWait1
|
||||
FinWait2
|
||||
CloseWait
|
||||
LastAck
|
||||
Closing
|
||||
TimeWait
|
||||
)
|
||||
|
||||
var states = map[State]string{
|
||||
Unknown: "unknown",
|
||||
Closed: "closed",
|
||||
Listen: "listen",
|
||||
SynSent: "syn-sent",
|
||||
SynReceived: "syn-received",
|
||||
Established: "established",
|
||||
FinWait1: "fin-wait-1",
|
||||
FinWait2: "fin-wait-2",
|
||||
CloseWait: "close-wait",
|
||||
LastAck: "last-ack",
|
||||
Closing: "closing",
|
||||
TimeWait: "time-wait",
|
||||
}
|
||||
|
||||
func (st State) String() string {
|
||||
s, ok := states[st]
|
||||
if !ok {
|
||||
return "<nil>"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// An OptionKind represents an option kind.
|
||||
type OptionKind int
|
||||
|
||||
const (
|
||||
KindMaxSegSize OptionKind = 2
|
||||
KindWindowScale OptionKind = 3
|
||||
KindSACKPermitted OptionKind = 4
|
||||
KindTimestamps OptionKind = 8
|
||||
)
|
||||
|
||||
var optionKinds = map[OptionKind]string{
|
||||
KindMaxSegSize: "mss",
|
||||
KindWindowScale: "wscale",
|
||||
KindSACKPermitted: "sack",
|
||||
KindTimestamps: "tmstamps",
|
||||
}
|
||||
|
||||
func (k OptionKind) String() string {
|
||||
s, ok := optionKinds[k]
|
||||
if !ok {
|
||||
return "<nil>"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// An Option represents an option.
|
||||
type Option interface {
|
||||
Kind() OptionKind
|
||||
}
|
||||
|
||||
// A MaxSegSize represents a maxiumum segment size option.
|
||||
type MaxSegSize uint
|
||||
|
||||
// Kind returns an option kind field.
|
||||
func (mss MaxSegSize) Kind() OptionKind { return KindMaxSegSize }
|
||||
|
||||
// A WindowScale represents a windows scale option.
|
||||
type WindowScale int
|
||||
|
||||
// Kind returns an option kind field.
|
||||
func (ws WindowScale) Kind() OptionKind { return KindWindowScale }
|
||||
|
||||
// A SACKPermitted reports whether a selective acknowledgment
|
||||
// permitted option is enabled.
|
||||
type SACKPermitted bool
|
||||
|
||||
// Kind returns an option kind field.
|
||||
func (sp SACKPermitted) Kind() OptionKind { return KindSACKPermitted }
|
||||
|
||||
// A Timestamps reports whether a timestamps option is enabled.
|
||||
type Timestamps bool
|
||||
|
||||
// Kind returns an option kind field.
|
||||
func (ts Timestamps) Kind() OptionKind { return KindTimestamps }
|
||||
35
vendor/github.com/mikioh/tcpinfo/zsys_2_6_10_linux.go
generated
vendored
Normal file
35
vendor/github.com/mikioh/tcpinfo/zsys_2_6_10_linux.go
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
package tcpinfo
|
||||
|
||||
type tcpInfo2_6_10 struct {
|
||||
State uint8
|
||||
Ca_state uint8
|
||||
Retransmits uint8
|
||||
Probes uint8
|
||||
Backoff uint8
|
||||
Options uint8
|
||||
Pad_cgo_0 [2]byte
|
||||
Rto uint32
|
||||
Ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
Unacked uint32
|
||||
Sacked uint32
|
||||
Lost uint32
|
||||
Retrans uint32
|
||||
Fackets uint32
|
||||
Last_data_sent uint32
|
||||
Last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
Last_ack_recv uint32
|
||||
Pmtu uint32
|
||||
Rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Advmss uint32
|
||||
Reordering uint32
|
||||
Rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Total_retrans uint32
|
||||
}
|
||||
42
vendor/github.com/mikioh/tcpinfo/zsys_3_19_linux.go
generated
vendored
Normal file
42
vendor/github.com/mikioh/tcpinfo/zsys_3_19_linux.go
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// go tool cgo -godefs defs_linux.go
|
||||
// it was edited to remove duplicated code. Also removed last field (tcpi_last_new_data_recv)
|
||||
// because we do not use it and getsockopt does not fill it anyway
|
||||
|
||||
package tcpinfo
|
||||
|
||||
type tcpInfo3_19 struct {
|
||||
State uint8
|
||||
Ca_state uint8
|
||||
Retransmits uint8
|
||||
Probes uint8
|
||||
Backoff uint8
|
||||
Options uint8
|
||||
Pad_cgo_0 [2]byte
|
||||
Rto uint32
|
||||
Ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
Unacked uint32
|
||||
Sacked uint32
|
||||
Lost uint32
|
||||
Retrans uint32
|
||||
Fackets uint32
|
||||
Last_data_sent uint32
|
||||
Last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
Last_ack_recv uint32
|
||||
Pmtu uint32
|
||||
Rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Advmss uint32
|
||||
Reordering uint32
|
||||
Rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Total_retrans uint32
|
||||
Pacing_rate uint64
|
||||
Max_pacing_rate uint64
|
||||
}
|
||||
45
vendor/github.com/mikioh/tcpinfo/zsys_darwin.go
generated
vendored
Normal file
45
vendor/github.com/mikioh/tcpinfo/zsys_darwin.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_darwin.go
|
||||
|
||||
package tcpinfo
|
||||
|
||||
const (
|
||||
sysTCP_CONNECTION_INFO = 0x106
|
||||
|
||||
sysTCPCI_OPT_TIMESTAMPS = 0x1
|
||||
sysTCPCI_OPT_SACK = 0x2
|
||||
sysTCPCI_OPT_WSCALE = 0x4
|
||||
sysTCPCI_OPT_ECN = 0x8
|
||||
|
||||
SysFlagLossRecovery SysFlags = 0x1
|
||||
SysFlagReorderingDetected SysFlags = 0x2
|
||||
|
||||
sizeofTCPConnectionInfo = 0x70
|
||||
)
|
||||
|
||||
type tcpConnectionInfo struct {
|
||||
State uint8
|
||||
Snd_wscale uint8
|
||||
Rcv_wscale uint8
|
||||
X__pad1 uint8
|
||||
Options uint32
|
||||
Flags uint32
|
||||
Rto uint32
|
||||
Maxseg uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Snd_wnd uint32
|
||||
Snd_sbbytes uint32
|
||||
Rcv_wnd uint32
|
||||
Rttcur uint32
|
||||
Srtt uint32
|
||||
Rttvar uint32
|
||||
Pad_cgo_0 [4]byte
|
||||
Txpackets uint64
|
||||
Txbytes uint64
|
||||
Txretransmitbytes uint64
|
||||
Rxpackets uint64
|
||||
Rxbytes uint64
|
||||
Rxoutoforderbytes uint64
|
||||
Txretransmitpackets uint64
|
||||
}
|
||||
58
vendor/github.com/mikioh/tcpinfo/zsys_freebsd.go
generated
vendored
Normal file
58
vendor/github.com/mikioh/tcpinfo/zsys_freebsd.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_freebsd.go
|
||||
|
||||
package tcpinfo
|
||||
|
||||
const (
|
||||
sysTCP_INFO = 0x20
|
||||
|
||||
sysTCPI_OPT_TIMESTAMPS = 0x1
|
||||
sysTCPI_OPT_SACK = 0x2
|
||||
sysTCPI_OPT_WSCALE = 0x4
|
||||
sysTCPI_OPT_ECN = 0x8
|
||||
sysTCPI_OPT_TOE = 0x10
|
||||
|
||||
sizeofTCPInfo = 0xec
|
||||
)
|
||||
|
||||
type tcpInfo struct {
|
||||
State uint8
|
||||
X__tcpi_ca_state uint8
|
||||
X__tcpi_retransmits uint8
|
||||
X__tcpi_probes uint8
|
||||
X__tcpi_backoff uint8
|
||||
Options uint8
|
||||
Pad_cgo_0 [2]byte
|
||||
Rto uint32
|
||||
X__tcpi_ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
X__tcpi_unacked uint32
|
||||
X__tcpi_sacked uint32
|
||||
X__tcpi_lost uint32
|
||||
X__tcpi_retrans uint32
|
||||
X__tcpi_fackets uint32
|
||||
X__tcpi_last_data_sent uint32
|
||||
X__tcpi_last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
X__tcpi_last_ack_recv uint32
|
||||
X__tcpi_pmtu uint32
|
||||
X__tcpi_rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
X__tcpi_advmss uint32
|
||||
X__tcpi_reordering uint32
|
||||
X__tcpi_rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Snd_wnd uint32
|
||||
Snd_bwnd uint32
|
||||
Snd_nxt uint32
|
||||
Rcv_nxt uint32
|
||||
Toe_tid uint32
|
||||
Snd_rexmitpack uint32
|
||||
Rcv_ooopack uint32
|
||||
Snd_zerowin uint32
|
||||
X__tcpi_pad [26]uint32
|
||||
}
|
||||
103
vendor/github.com/mikioh/tcpinfo/zsys_linux.go
generated
vendored
Normal file
103
vendor/github.com/mikioh/tcpinfo/zsys_linux.go
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_linux.go
|
||||
|
||||
package tcpinfo
|
||||
|
||||
const (
|
||||
sysTCP_INFO = 0xb
|
||||
sysTCP_CONGESTION = 0xd
|
||||
sysTCP_CC_INFO = 0x1a
|
||||
|
||||
sysTCPI_OPT_TIMESTAMPS = 0x1
|
||||
sysTCPI_OPT_SACK = 0x2
|
||||
sysTCPI_OPT_WSCALE = 0x4
|
||||
sysTCPI_OPT_ECN = 0x8
|
||||
sysTCPI_OPT_ECN_SEEN = 0x10
|
||||
sysTCPI_OPT_SYN_DATA = 0x20
|
||||
|
||||
CAOpen CAState = 0x0
|
||||
CADisorder CAState = 0x1
|
||||
CACWR CAState = 0x2
|
||||
CARecovery CAState = 0x3
|
||||
CALoss CAState = 0x4
|
||||
|
||||
sizeofTCPInfo = 0xc0
|
||||
sizeofTCPCCInfo = 0x14
|
||||
sizeofTCPVegasInfo = 0x10
|
||||
sizeofTCPDCTCPInfo = 0x10
|
||||
sizeofTCPBBRInfo = 0x14
|
||||
)
|
||||
|
||||
type tcpInfo struct {
|
||||
State uint8
|
||||
Ca_state uint8
|
||||
Retransmits uint8
|
||||
Probes uint8
|
||||
Backoff uint8
|
||||
Options uint8
|
||||
Pad_cgo_0 [1]byte
|
||||
Pad_cgo_1 [1]byte
|
||||
Rto uint32
|
||||
Ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
Unacked uint32
|
||||
Sacked uint32
|
||||
Lost uint32
|
||||
Retrans uint32
|
||||
Fackets uint32
|
||||
Last_data_sent uint32
|
||||
Last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
Last_ack_recv uint32
|
||||
Pmtu uint32
|
||||
Rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
Advmss uint32
|
||||
Reordering uint32
|
||||
Rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Total_retrans uint32
|
||||
Pacing_rate uint64
|
||||
Max_pacing_rate uint64
|
||||
Bytes_acked uint64
|
||||
Bytes_received uint64
|
||||
Segs_out uint32
|
||||
Segs_in uint32
|
||||
Notsent_bytes uint32
|
||||
Min_rtt uint32
|
||||
Data_segs_in uint32
|
||||
Data_segs_out uint32
|
||||
Delivery_rate uint64
|
||||
Busy_time uint64
|
||||
Rwnd_limited uint64
|
||||
Sndbuf_limited uint64
|
||||
}
|
||||
|
||||
type tcpCCInfo [20]byte
|
||||
|
||||
type tcpVegasInfo struct {
|
||||
Enabled uint32
|
||||
Rttcnt uint32
|
||||
Rtt uint32
|
||||
Minrtt uint32
|
||||
}
|
||||
|
||||
type tcpDCTCPInfo struct {
|
||||
Enabled uint16
|
||||
Ce_state uint16
|
||||
Alpha uint32
|
||||
Ab_ecn uint32
|
||||
Ab_tot uint32
|
||||
}
|
||||
|
||||
type tcpBBRInfo struct {
|
||||
Bw_lo uint32
|
||||
Bw_hi uint32
|
||||
Min_rtt uint32
|
||||
Pacing_gain uint32
|
||||
Cwnd_gain uint32
|
||||
}
|
||||
58
vendor/github.com/mikioh/tcpinfo/zsys_netbsd.go
generated
vendored
Normal file
58
vendor/github.com/mikioh/tcpinfo/zsys_netbsd.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_netbsd.go
|
||||
|
||||
package tcpinfo
|
||||
|
||||
const (
|
||||
sysTCP_INFO = 0x9
|
||||
|
||||
sysTCPI_OPT_TIMESTAMPS = 0x1
|
||||
sysTCPI_OPT_SACK = 0x2
|
||||
sysTCPI_OPT_WSCALE = 0x4
|
||||
sysTCPI_OPT_ECN = 0x8
|
||||
sysTCPI_OPT_TOE = 0x10
|
||||
|
||||
sizeofTCPInfo = 0xec
|
||||
)
|
||||
|
||||
type tcpInfo struct {
|
||||
State uint8
|
||||
X__tcpi_ca_state uint8
|
||||
X__tcpi_retransmits uint8
|
||||
X__tcpi_probes uint8
|
||||
X__tcpi_backoff uint8
|
||||
Options uint8
|
||||
Pad_cgo_0 [2]byte
|
||||
Rto uint32
|
||||
X__tcpi_ato uint32
|
||||
Snd_mss uint32
|
||||
Rcv_mss uint32
|
||||
X__tcpi_unacked uint32
|
||||
X__tcpi_sacked uint32
|
||||
X__tcpi_lost uint32
|
||||
X__tcpi_retrans uint32
|
||||
X__tcpi_fackets uint32
|
||||
X__tcpi_last_data_sent uint32
|
||||
X__tcpi_last_ack_sent uint32
|
||||
Last_data_recv uint32
|
||||
X__tcpi_last_ack_recv uint32
|
||||
X__tcpi_pmtu uint32
|
||||
X__tcpi_rcv_ssthresh uint32
|
||||
Rtt uint32
|
||||
Rttvar uint32
|
||||
Snd_ssthresh uint32
|
||||
Snd_cwnd uint32
|
||||
X__tcpi_advmss uint32
|
||||
X__tcpi_reordering uint32
|
||||
X__tcpi_rcv_rtt uint32
|
||||
Rcv_space uint32
|
||||
Snd_wnd uint32
|
||||
Snd_bwnd uint32
|
||||
Snd_nxt uint32
|
||||
Rcv_nxt uint32
|
||||
Toe_tid uint32
|
||||
Snd_rexmitpack uint32
|
||||
Rcv_ooopack uint32
|
||||
Snd_zerowin uint32
|
||||
X__tcpi_pad [26]uint32
|
||||
}
|
||||
Reference in New Issue
Block a user