TUN-3161: Upgrade golang.org/x/ deps
This commit is contained in:
parent
92765b4261
commit
a99780ed9d
6
go.mod
6
go.mod
|
@ -57,11 +57,11 @@ require (
|
||||||
github.com/stretchr/testify v1.3.0
|
github.com/stretchr/testify v1.3.0
|
||||||
github.com/tinylib/msgp v1.1.0 // indirect
|
github.com/tinylib/msgp v1.1.0 // indirect
|
||||||
github.com/xo/dburl v0.0.0-20191005012637-293c3298d6c0
|
github.com/xo/dburl v0.0.0-20191005012637-293c3298d6c0
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58
|
||||||
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2
|
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
|
||||||
google.golang.org/appengine v1.5.0 // indirect
|
google.golang.org/appengine v1.5.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20191007204434-a023cd5227bd // indirect
|
google.golang.org/genproto v0.0.0-20191007204434-a023cd5227bd // indirect
|
||||||
google.golang.org/grpc v1.24.0 // indirect
|
google.golang.org/grpc v1.24.0 // indirect
|
||||||
|
|
7
go.sum
7
go.sum
|
@ -206,6 +206,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
@ -224,6 +226,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 h1:p9xBe/w/OzkeYVKm234g55gMdD1nSIooTir5kV11kfA=
|
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 h1:p9xBe/w/OzkeYVKm234g55gMdD1nSIooTir5kV11kfA=
|
||||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
|
||||||
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||||
|
@ -245,6 +249,9 @@ golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9Y
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2 h1:nq114VpM8lsSlP+lyUbANecYHYiFcSNFtqcBlxRV+gA=
|
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2 h1:nq114VpM8lsSlP+lyUbANecYHYiFcSNFtqcBlxRV+gA=
|
||||||
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
|
||||||
|
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
||||||
|
|
||||||
// during the authentication phase the client first attempts the "none" method
|
// during the authentication phase the client first attempts the "none" method
|
||||||
// then any untried methods suggested by the server.
|
// then any untried methods suggested by the server.
|
||||||
tried := make(map[string]bool)
|
var tried []string
|
||||||
var lastMethods []string
|
var lastMethods []string
|
||||||
|
|
||||||
sessionID := c.transport.getSessionID()
|
sessionID := c.transport.getSessionID()
|
||||||
|
@ -49,7 +49,9 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
||||||
// success
|
// success
|
||||||
return nil
|
return nil
|
||||||
} else if ok == authFailure {
|
} else if ok == authFailure {
|
||||||
tried[auth.method()] = true
|
if m := auth.method(); !contains(tried, m) {
|
||||||
|
tried = append(tried, m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if methods == nil {
|
if methods == nil {
|
||||||
methods = lastMethods
|
methods = lastMethods
|
||||||
|
@ -61,7 +63,7 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
||||||
findNext:
|
findNext:
|
||||||
for _, a := range config.Auth {
|
for _, a := range config.Auth {
|
||||||
candidateMethod := a.method()
|
candidateMethod := a.method()
|
||||||
if tried[candidateMethod] {
|
if contains(tried, candidateMethod) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, meth := range methods {
|
for _, meth := range methods {
|
||||||
|
@ -72,16 +74,16 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", keys(tried))
|
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", tried)
|
||||||
}
|
}
|
||||||
|
|
||||||
func keys(m map[string]bool) []string {
|
func contains(list []string, e string) bool {
|
||||||
s := make([]string, 0, len(m))
|
for _, s := range list {
|
||||||
|
if s == e {
|
||||||
for key := range m {
|
return true
|
||||||
s = append(s, key)
|
|
||||||
}
|
}
|
||||||
return s
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// An AuthMethod represents an instance of an RFC 4252 authentication method.
|
// An AuthMethod represents an instance of an RFC 4252 authentication method.
|
||||||
|
|
|
@ -107,6 +107,7 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis
|
||||||
|
|
||||||
// dialCall is an in-flight Transport dial call to a host.
|
// dialCall is an in-flight Transport dial call to a host.
|
||||||
type dialCall struct {
|
type dialCall struct {
|
||||||
|
_ incomparable
|
||||||
p *clientConnPool
|
p *clientConnPool
|
||||||
done chan struct{} // closed when done
|
done chan struct{} // closed when done
|
||||||
res *ClientConn // valid after done is closed
|
res *ClientConn // valid after done is closed
|
||||||
|
@ -180,6 +181,7 @@ func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c *tls.Conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
type addConnCall struct {
|
type addConnCall struct {
|
||||||
|
_ incomparable
|
||||||
p *clientConnPool
|
p *clientConnPool
|
||||||
done chan struct{} // closed when done
|
done chan struct{} // closed when done
|
||||||
err error
|
err error
|
||||||
|
@ -200,12 +202,6 @@ func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) {
|
||||||
close(c.done)
|
close(c.done)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *clientConnPool) addConn(key string, cc *ClientConn) {
|
|
||||||
p.mu.Lock()
|
|
||||||
p.addConnLocked(key, cc)
|
|
||||||
p.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// p.mu must be held
|
// p.mu must be held
|
||||||
func (p *clientConnPool) addConnLocked(key string, cc *ClientConn) {
|
func (p *clientConnPool) addConnLocked(key string, cc *ClientConn) {
|
||||||
for _, v := range p.conns[key] {
|
for _, v := range p.conns[key] {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package http2
|
||||||
|
|
||||||
// flow is the flow control window's size.
|
// flow is the flow control window's size.
|
||||||
type flow struct {
|
type flow struct {
|
||||||
|
_ incomparable
|
||||||
|
|
||||||
// n is the number of DATA bytes we're allowed to send.
|
// n is the number of DATA bytes we're allowed to send.
|
||||||
// A flow is kept both on a conn and a per-stream.
|
// A flow is kept both on a conn and a per-stream.
|
||||||
n int32
|
n int32
|
||||||
|
|
|
@ -105,7 +105,14 @@ func huffmanDecode(buf *bytes.Buffer, maxLen int, v []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incomparable is a zero-width, non-comparable type. Adding it to a struct
|
||||||
|
// makes that struct also non-comparable, and generally doesn't add
|
||||||
|
// any size (as long as it's first).
|
||||||
|
type incomparable [0]func()
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
|
_ incomparable
|
||||||
|
|
||||||
// children is non-nil for internal nodes
|
// children is non-nil for internal nodes
|
||||||
children *[256]*node
|
children *[256]*node
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ package http2 // import "golang.org/x/net/http2"
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -173,11 +172,6 @@ func (s SettingID) String() string {
|
||||||
return fmt.Sprintf("UNKNOWN_SETTING_%d", uint16(s))
|
return fmt.Sprintf("UNKNOWN_SETTING_%d", uint16(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
errInvalidHeaderFieldName = errors.New("http2: invalid header field name")
|
|
||||||
errInvalidHeaderFieldValue = errors.New("http2: invalid header field value")
|
|
||||||
)
|
|
||||||
|
|
||||||
// validWireHeaderFieldName reports whether v is a valid header field
|
// validWireHeaderFieldName reports whether v is a valid header field
|
||||||
// name (key). See httpguts.ValidHeaderName for the base rules.
|
// name (key). See httpguts.ValidHeaderName for the base rules.
|
||||||
//
|
//
|
||||||
|
@ -247,6 +241,7 @@ func (cw closeWaiter) Wait() {
|
||||||
// Its buffered writer is lazily allocated as needed, to minimize
|
// Its buffered writer is lazily allocated as needed, to minimize
|
||||||
// idle memory usage with many connections.
|
// idle memory usage with many connections.
|
||||||
type bufferedWriter struct {
|
type bufferedWriter struct {
|
||||||
|
_ incomparable
|
||||||
w io.Writer // immutable
|
w io.Writer // immutable
|
||||||
bw *bufio.Writer // non-nil when data is buffered
|
bw *bufio.Writer // non-nil when data is buffered
|
||||||
}
|
}
|
||||||
|
@ -319,6 +314,7 @@ func bodyAllowedForStatus(status int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
type httpError struct {
|
type httpError struct {
|
||||||
|
_ incomparable
|
||||||
msg string
|
msg string
|
||||||
timeout bool
|
timeout bool
|
||||||
}
|
}
|
||||||
|
@ -382,3 +378,8 @@ func (s *sorter) SortStrings(ss []string) {
|
||||||
func validPseudoPath(v string) bool {
|
func validPseudoPath(v string) bool {
|
||||||
return (len(v) > 0 && v[0] == '/') || v == "*"
|
return (len(v) > 0 && v[0] == '/') || v == "*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incomparable is a zero-width, non-comparable type. Adding it to a struct
|
||||||
|
// makes that struct also non-comparable, and generally doesn't add
|
||||||
|
// any size (as long as it's first).
|
||||||
|
type incomparable [0]func()
|
||||||
|
|
|
@ -252,7 +252,7 @@ func ConfigureServer(s *http.Server, conf *Server) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !haveRequired {
|
if !haveRequired {
|
||||||
return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher.")
|
return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher (need at least one of TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 or TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256).")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,9 +585,6 @@ type stream struct {
|
||||||
declBodyBytes int64 // or -1 if undeclared
|
declBodyBytes int64 // or -1 if undeclared
|
||||||
flow flow // limits writing from Handler to client
|
flow flow // limits writing from Handler to client
|
||||||
inflow flow // what the client is allowed to POST/etc to us
|
inflow flow // what the client is allowed to POST/etc to us
|
||||||
parent *stream // or nil
|
|
||||||
numTrailerValues int64
|
|
||||||
weight uint8
|
|
||||||
state streamState
|
state streamState
|
||||||
resetQueued bool // RST_STREAM queued for write; set by sc.resetStream
|
resetQueued bool // RST_STREAM queued for write; set by sc.resetStream
|
||||||
gotTrailerHeader bool // HEADER frame for trailers was seen
|
gotTrailerHeader bool // HEADER frame for trailers was seen
|
||||||
|
@ -764,6 +761,7 @@ func (sc *serverConn) readFrames() {
|
||||||
|
|
||||||
// frameWriteResult is the message passed from writeFrameAsync to the serve goroutine.
|
// frameWriteResult is the message passed from writeFrameAsync to the serve goroutine.
|
||||||
type frameWriteResult struct {
|
type frameWriteResult struct {
|
||||||
|
_ incomparable
|
||||||
wr FrameWriteRequest // what was written (or attempted)
|
wr FrameWriteRequest // what was written (or attempted)
|
||||||
err error // result of the writeFrame call
|
err error // result of the writeFrame call
|
||||||
}
|
}
|
||||||
|
@ -774,7 +772,7 @@ type frameWriteResult struct {
|
||||||
// serverConn.
|
// serverConn.
|
||||||
func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest) {
|
func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest) {
|
||||||
err := wr.write.writeFrame(sc)
|
err := wr.write.writeFrame(sc)
|
||||||
sc.wroteFrameCh <- frameWriteResult{wr, err}
|
sc.wroteFrameCh <- frameWriteResult{wr: wr, err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *serverConn) closeAllStreamsOnConnClose() {
|
func (sc *serverConn) closeAllStreamsOnConnClose() {
|
||||||
|
@ -1164,7 +1162,7 @@ func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) {
|
||||||
if wr.write.staysWithinBuffer(sc.bw.Available()) {
|
if wr.write.staysWithinBuffer(sc.bw.Available()) {
|
||||||
sc.writingFrameAsync = false
|
sc.writingFrameAsync = false
|
||||||
err := wr.write.writeFrame(sc)
|
err := wr.write.writeFrame(sc)
|
||||||
sc.wroteFrame(frameWriteResult{wr, err})
|
sc.wroteFrame(frameWriteResult{wr: wr, err: err})
|
||||||
} else {
|
} else {
|
||||||
sc.writingFrameAsync = true
|
sc.writingFrameAsync = true
|
||||||
go sc.writeFrameAsync(wr)
|
go sc.writeFrameAsync(wr)
|
||||||
|
@ -2060,7 +2058,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r
|
||||||
var trailer http.Header
|
var trailer http.Header
|
||||||
for _, v := range rp.header["Trailer"] {
|
for _, v := range rp.header["Trailer"] {
|
||||||
for _, key := range strings.Split(v, ",") {
|
for _, key := range strings.Split(v, ",") {
|
||||||
key = http.CanonicalHeaderKey(strings.TrimSpace(key))
|
key = http.CanonicalHeaderKey(textproto.TrimString(key))
|
||||||
switch key {
|
switch key {
|
||||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||||
// Bogus. (copy of http1 rules)
|
// Bogus. (copy of http1 rules)
|
||||||
|
@ -2278,6 +2276,7 @@ func (sc *serverConn) sendWindowUpdate32(st *stream, n int32) {
|
||||||
// requestBody is the Handler's Request.Body type.
|
// requestBody is the Handler's Request.Body type.
|
||||||
// Read and Close may be called concurrently.
|
// Read and Close may be called concurrently.
|
||||||
type requestBody struct {
|
type requestBody struct {
|
||||||
|
_ incomparable
|
||||||
stream *stream
|
stream *stream
|
||||||
conn *serverConn
|
conn *serverConn
|
||||||
closed bool // for use by Close only
|
closed bool // for use by Close only
|
||||||
|
|
|
@ -93,7 +93,7 @@ type Transport struct {
|
||||||
// send in the initial settings frame. It is how many bytes
|
// send in the initial settings frame. It is how many bytes
|
||||||
// of response headers are allowed. Unlike the http2 spec, zero here
|
// of response headers are allowed. Unlike the http2 spec, zero here
|
||||||
// means to use a default limit (currently 10MB). If you actually
|
// means to use a default limit (currently 10MB). If you actually
|
||||||
// want to advertise an ulimited value to the peer, Transport
|
// want to advertise an unlimited value to the peer, Transport
|
||||||
// interprets the highest possible value here (0xffffffff or 1<<32-1)
|
// interprets the highest possible value here (0xffffffff or 1<<32-1)
|
||||||
// to mean no limit.
|
// to mean no limit.
|
||||||
MaxHeaderListSize uint32
|
MaxHeaderListSize uint32
|
||||||
|
@ -108,6 +108,19 @@ type Transport struct {
|
||||||
// waiting for their turn.
|
// waiting for their turn.
|
||||||
StrictMaxConcurrentStreams bool
|
StrictMaxConcurrentStreams bool
|
||||||
|
|
||||||
|
// ReadIdleTimeout is the timeout after which a health check using ping
|
||||||
|
// frame will be carried out if no frame is received on the connection.
|
||||||
|
// Note that a ping response will is considered a received frame, so if
|
||||||
|
// there is no other traffic on the connection, the health check will
|
||||||
|
// be performed every ReadIdleTimeout interval.
|
||||||
|
// If zero, no health check is performed.
|
||||||
|
ReadIdleTimeout time.Duration
|
||||||
|
|
||||||
|
// PingTimeout is the timeout after which the connection will be closed
|
||||||
|
// if a response to Ping is not received.
|
||||||
|
// Defaults to 15s.
|
||||||
|
PingTimeout time.Duration
|
||||||
|
|
||||||
// t1, if non-nil, is the standard library Transport using
|
// t1, if non-nil, is the standard library Transport using
|
||||||
// this transport. Its settings are used (but not its
|
// this transport. Its settings are used (but not its
|
||||||
// RoundTrip method, etc).
|
// RoundTrip method, etc).
|
||||||
|
@ -131,6 +144,14 @@ func (t *Transport) disableCompression() bool {
|
||||||
return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
|
return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Transport) pingTimeout() time.Duration {
|
||||||
|
if t.PingTimeout == 0 {
|
||||||
|
return 15 * time.Second
|
||||||
|
}
|
||||||
|
return t.PingTimeout
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
|
// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
|
||||||
// It returns an error if t1 has already been HTTP/2-enabled.
|
// It returns an error if t1 has already been HTTP/2-enabled.
|
||||||
func ConfigureTransport(t1 *http.Transport) error {
|
func ConfigureTransport(t1 *http.Transport) error {
|
||||||
|
@ -227,6 +248,7 @@ type ClientConn struct {
|
||||||
br *bufio.Reader
|
br *bufio.Reader
|
||||||
fr *Framer
|
fr *Framer
|
||||||
lastActive time.Time
|
lastActive time.Time
|
||||||
|
lastIdle time.Time // time last idle
|
||||||
// Settings from peer: (also guarded by mu)
|
// Settings from peer: (also guarded by mu)
|
||||||
maxFrameSize uint32
|
maxFrameSize uint32
|
||||||
maxConcurrentStreams uint32
|
maxConcurrentStreams uint32
|
||||||
|
@ -674,6 +696,20 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
||||||
return cc, nil
|
return cc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) healthCheck() {
|
||||||
|
pingTimeout := cc.t.pingTimeout()
|
||||||
|
// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
|
||||||
|
// trigger the healthCheck again if there is no frame received.
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), pingTimeout)
|
||||||
|
defer cancel()
|
||||||
|
err := cc.Ping(ctx)
|
||||||
|
if err != nil {
|
||||||
|
cc.closeForLostPing()
|
||||||
|
cc.t.connPool().MarkDead(cc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
|
func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
|
||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
defer cc.mu.Unlock()
|
defer cc.mu.Unlock()
|
||||||
|
@ -736,7 +772,8 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
|
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
|
||||||
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32
|
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
|
||||||
|
!cc.tooIdleLocked()
|
||||||
st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest
|
st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -746,6 +783,16 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
||||||
return st.canTakeNewRequest
|
return st.canTakeNewRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tooIdleLocked reports whether this connection has been been sitting idle
|
||||||
|
// for too much wall time.
|
||||||
|
func (cc *ClientConn) tooIdleLocked() bool {
|
||||||
|
// The Round(0) strips the monontonic clock reading so the
|
||||||
|
// times are compared based on their wall time. We don't want
|
||||||
|
// to reuse a connection that's been sitting idle during
|
||||||
|
// VM/laptop suspend if monotonic time was also frozen.
|
||||||
|
return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && time.Since(cc.lastIdle.Round(0)) > cc.idleTimeout
|
||||||
|
}
|
||||||
|
|
||||||
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
||||||
// only be called when we're idle, but because we're coming from a new
|
// only be called when we're idle, but because we're coming from a new
|
||||||
// goroutine, there could be a new request coming in at the same time,
|
// goroutine, there could be a new request coming in at the same time,
|
||||||
|
@ -834,14 +881,12 @@ func (cc *ClientConn) sendGoAway() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the client connection immediately.
|
// closes the client connection immediately. In-flight requests are interrupted.
|
||||||
//
|
// err is sent to streams.
|
||||||
// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
|
func (cc *ClientConn) closeForError(err error) error {
|
||||||
func (cc *ClientConn) Close() error {
|
|
||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
defer cc.cond.Broadcast()
|
defer cc.cond.Broadcast()
|
||||||
defer cc.mu.Unlock()
|
defer cc.mu.Unlock()
|
||||||
err := errors.New("http2: client connection force closed via ClientConn.Close")
|
|
||||||
for id, cs := range cc.streams {
|
for id, cs := range cc.streams {
|
||||||
select {
|
select {
|
||||||
case cs.resc <- resAndError{err: err}:
|
case cs.resc <- resAndError{err: err}:
|
||||||
|
@ -854,6 +899,20 @@ func (cc *ClientConn) Close() error {
|
||||||
return cc.tconn.Close()
|
return cc.tconn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the client connection immediately.
|
||||||
|
//
|
||||||
|
// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
|
||||||
|
func (cc *ClientConn) Close() error {
|
||||||
|
err := errors.New("http2: client connection force closed via ClientConn.Close")
|
||||||
|
return cc.closeForError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// closes the client connection immediately. In-flight requests are interrupted.
|
||||||
|
func (cc *ClientConn) closeForLostPing() error {
|
||||||
|
err := errors.New("http2: client connection lost")
|
||||||
|
return cc.closeForError(err)
|
||||||
|
}
|
||||||
|
|
||||||
const maxAllocFrameSize = 512 << 10
|
const maxAllocFrameSize = 512 << 10
|
||||||
|
|
||||||
// frameBuffer returns a scratch buffer suitable for writing DATA frames.
|
// frameBuffer returns a scratch buffer suitable for writing DATA frames.
|
||||||
|
@ -904,7 +963,7 @@ func commaSeparatedTrailers(req *http.Request) (string, error) {
|
||||||
k = http.CanonicalHeaderKey(k)
|
k = http.CanonicalHeaderKey(k)
|
||||||
switch k {
|
switch k {
|
||||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||||
return "", &badStringError{"invalid Trailer key", k}
|
return "", fmt.Errorf("invalid Trailer key %q", k)
|
||||||
}
|
}
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
@ -1150,6 +1209,7 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
|
||||||
}
|
}
|
||||||
return errClientConnUnusable
|
return errClientConnUnusable
|
||||||
}
|
}
|
||||||
|
cc.lastIdle = time.Time{}
|
||||||
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
||||||
if waitingForConn != nil {
|
if waitingForConn != nil {
|
||||||
close(waitingForConn)
|
close(waitingForConn)
|
||||||
|
@ -1381,13 +1441,6 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type badStringError struct {
|
|
||||||
what string
|
|
||||||
str string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) }
|
|
||||||
|
|
||||||
// requires cc.mu be held.
|
// requires cc.mu be held.
|
||||||
func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
|
func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
|
||||||
cc.hbuf.Reset()
|
cc.hbuf.Reset()
|
||||||
|
@ -1603,6 +1656,7 @@ func (cc *ClientConn) writeHeader(name, value string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type resAndError struct {
|
type resAndError struct {
|
||||||
|
_ incomparable
|
||||||
res *http.Response
|
res *http.Response
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -1638,6 +1692,7 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
|
||||||
delete(cc.streams, id)
|
delete(cc.streams, id)
|
||||||
if len(cc.streams) == 0 && cc.idleTimer != nil {
|
if len(cc.streams) == 0 && cc.idleTimer != nil {
|
||||||
cc.idleTimer.Reset(cc.idleTimeout)
|
cc.idleTimer.Reset(cc.idleTimeout)
|
||||||
|
cc.lastIdle = time.Now()
|
||||||
}
|
}
|
||||||
close(cs.done)
|
close(cs.done)
|
||||||
// Wake up checkResetOrDone via clientStream.awaitFlowControl and
|
// Wake up checkResetOrDone via clientStream.awaitFlowControl and
|
||||||
|
@ -1649,6 +1704,7 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
|
||||||
|
|
||||||
// clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
|
// clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
|
||||||
type clientConnReadLoop struct {
|
type clientConnReadLoop struct {
|
||||||
|
_ incomparable
|
||||||
cc *ClientConn
|
cc *ClientConn
|
||||||
closeWhenIdle bool
|
closeWhenIdle bool
|
||||||
}
|
}
|
||||||
|
@ -1728,8 +1784,17 @@ func (rl *clientConnReadLoop) run() error {
|
||||||
rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
|
rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
|
||||||
gotReply := false // ever saw a HEADERS reply
|
gotReply := false // ever saw a HEADERS reply
|
||||||
gotSettings := false
|
gotSettings := false
|
||||||
|
readIdleTimeout := cc.t.ReadIdleTimeout
|
||||||
|
var t *time.Timer
|
||||||
|
if readIdleTimeout != 0 {
|
||||||
|
t = time.AfterFunc(readIdleTimeout, cc.healthCheck)
|
||||||
|
defer t.Stop()
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
f, err := cc.fr.ReadFrame()
|
f, err := cc.fr.ReadFrame()
|
||||||
|
if t != nil {
|
||||||
|
t.Reset(readIdleTimeout)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
|
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
|
||||||
}
|
}
|
||||||
|
@ -1878,7 +1943,9 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
|
||||||
return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
|
return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
|
||||||
}
|
}
|
||||||
|
|
||||||
header := make(http.Header)
|
regularFields := f.RegularFields()
|
||||||
|
strs := make([]string, len(regularFields))
|
||||||
|
header := make(http.Header, len(regularFields))
|
||||||
res := &http.Response{
|
res := &http.Response{
|
||||||
Proto: "HTTP/2.0",
|
Proto: "HTTP/2.0",
|
||||||
ProtoMajor: 2,
|
ProtoMajor: 2,
|
||||||
|
@ -1886,7 +1953,7 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
|
||||||
StatusCode: statusCode,
|
StatusCode: statusCode,
|
||||||
Status: status + " " + http.StatusText(statusCode),
|
Status: status + " " + http.StatusText(statusCode),
|
||||||
}
|
}
|
||||||
for _, hf := range f.RegularFields() {
|
for _, hf := range regularFields {
|
||||||
key := http.CanonicalHeaderKey(hf.Name)
|
key := http.CanonicalHeaderKey(hf.Name)
|
||||||
if key == "Trailer" {
|
if key == "Trailer" {
|
||||||
t := res.Trailer
|
t := res.Trailer
|
||||||
|
@ -1898,7 +1965,18 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
|
||||||
t[http.CanonicalHeaderKey(v)] = nil
|
t[http.CanonicalHeaderKey(v)] = nil
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
header[key] = append(header[key], hf.Value)
|
vv := header[key]
|
||||||
|
if vv == nil && len(strs) > 0 {
|
||||||
|
// More than likely this will be a single-element key.
|
||||||
|
// Most headers aren't multi-valued.
|
||||||
|
// Set the capacity on strs[0] to 1, so any future append
|
||||||
|
// won't extend the slice into the other strings.
|
||||||
|
vv, strs = strs[:1:1], strs[1:]
|
||||||
|
vv[0] = hf.Value
|
||||||
|
header[key] = vv
|
||||||
|
} else {
|
||||||
|
header[key] = append(vv, hf.Value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,8 +2262,6 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errInvalidTrailers = errors.New("http2: invalid trailers")
|
|
||||||
|
|
||||||
func (rl *clientConnReadLoop) endStream(cs *clientStream) {
|
func (rl *clientConnReadLoop) endStream(cs *clientStream) {
|
||||||
// TODO: check that any declared content-length matches, like
|
// TODO: check that any declared content-length matches, like
|
||||||
// server.go's (*stream).endStream method.
|
// server.go's (*stream).endStream method.
|
||||||
|
@ -2416,7 +2492,6 @@ func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error)
|
||||||
var (
|
var (
|
||||||
errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit")
|
errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit")
|
||||||
errRequestHeaderListSize = errors.New("http2: request header list larger than peer's advertised limit")
|
errRequestHeaderListSize = errors.New("http2: request header list larger than peer's advertised limit")
|
||||||
errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cc *ClientConn) logf(format string, args ...interface{}) {
|
func (cc *ClientConn) logf(format string, args ...interface{}) {
|
||||||
|
@ -2455,6 +2530,7 @@ func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
|
||||||
// gzipReader wraps a response body so it can lazily
|
// gzipReader wraps a response body so it can lazily
|
||||||
// call gzip.NewReader on the first call to Read
|
// call gzip.NewReader on the first call to Read
|
||||||
type gzipReader struct {
|
type gzipReader struct {
|
||||||
|
_ incomparable
|
||||||
body io.ReadCloser // underlying Response.Body
|
body io.ReadCloser // underlying Response.Body
|
||||||
zr *gzip.Reader // lazily-initialized gzip reader
|
zr *gzip.Reader // lazily-initialized gzip reader
|
||||||
zerr error // sticky error
|
zerr error // sticky error
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
// +build go1.13
|
// +build go1.13,!go1.14
|
||||||
|
|
||||||
package idna
|
package idna
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2019 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 !race
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (m *Message) raceRead() {
|
||||||
|
}
|
||||||
|
func (m *Message) raceWrite() {
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright 2019 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 race
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This package reads and writes the Message buffers using a
|
||||||
|
// direct system call, which the race detector can't see.
|
||||||
|
// These functions tell the race detector what is going on during the syscall.
|
||||||
|
|
||||||
|
func (m *Message) raceRead() {
|
||||||
|
for _, b := range m.Buffers {
|
||||||
|
if len(b) > 0 {
|
||||||
|
runtime.RaceReadRange(unsafe.Pointer(&b[0]), len(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if b := m.OOB; len(b) > 0 {
|
||||||
|
runtime.RaceReadRange(unsafe.Pointer(&b[0]), len(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *Message) raceWrite() {
|
||||||
|
for _, b := range m.Buffers {
|
||||||
|
if len(b) > 0 {
|
||||||
|
runtime.RaceWriteRange(unsafe.Pointer(&b[0]), len(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if b := m.OOB; len(b) > 0 {
|
||||||
|
runtime.RaceWriteRange(unsafe.Pointer(&b[0]), len(b))
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
||||||
|
for i := range ms {
|
||||||
|
ms[i].raceWrite()
|
||||||
|
}
|
||||||
hs := make(mmsghdrs, len(ms))
|
hs := make(mmsghdrs, len(ms))
|
||||||
var parseFn func([]byte, string) (net.Addr, error)
|
var parseFn func([]byte, string) (net.Addr, error)
|
||||||
if c.network != "tcp" {
|
if c.network != "tcp" {
|
||||||
|
@ -43,6 +46,9 @@ func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
|
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
|
||||||
|
for i := range ms {
|
||||||
|
ms[i].raceRead()
|
||||||
|
}
|
||||||
hs := make(mmsghdrs, len(ms))
|
hs := make(mmsghdrs, len(ms))
|
||||||
var marshalFn func(net.Addr) []byte
|
var marshalFn func(net.Addr) []byte
|
||||||
if c.network != "tcp" {
|
if c.network != "tcp" {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Conn) recvMsg(m *Message, flags int) error {
|
func (c *Conn) recvMsg(m *Message, flags int) error {
|
||||||
|
m.raceWrite()
|
||||||
var h msghdr
|
var h msghdr
|
||||||
vs := make([]iovec, len(m.Buffers))
|
vs := make([]iovec, len(m.Buffers))
|
||||||
var sa []byte
|
var sa []byte
|
||||||
|
@ -48,6 +49,7 @@ func (c *Conn) recvMsg(m *Message, flags int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) sendMsg(m *Message, flags int) error {
|
func (c *Conn) sendMsg(m *Message, flags int) error {
|
||||||
|
m.raceRead()
|
||||||
var h msghdr
|
var h msghdr
|
||||||
vs := make([]iovec, len(m.Buffers))
|
vs := make([]iovec, len(m.Buffers))
|
||||||
var sa []byte
|
var sa []byte
|
||||||
|
|
|
@ -4,4 +4,29 @@
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
func probeProtocolStack() int { return 4 }
|
import (
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h
|
||||||
|
var (
|
||||||
|
osreldateOnce sync.Once
|
||||||
|
osreldate uint32
|
||||||
|
)
|
||||||
|
|
||||||
|
// First __DragonFly_version after September 2019 ABI changes
|
||||||
|
// http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html
|
||||||
|
const _dragonflyABIChangeVersion = 500705
|
||||||
|
|
||||||
|
func probeProtocolStack() int {
|
||||||
|
osreldateOnce.Do(func() { osreldate, _ = syscall.SysctlUint32("kern.osreldate") })
|
||||||
|
var p uintptr
|
||||||
|
if int(unsafe.Sizeof(p)) == 8 && osreldate >= _dragonflyABIChangeVersion {
|
||||||
|
return int(unsafe.Sizeof(p))
|
||||||
|
}
|
||||||
|
// 64-bit Dragonfly before the September 2019 ABI changes still requires
|
||||||
|
// 32-bit aligned access to network subsystem.
|
||||||
|
return 4
|
||||||
|
}
|
||||||
|
|
|
@ -403,9 +403,9 @@ func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, resu
|
||||||
|
|
||||||
// Where should scanning start?
|
// Where should scanning start?
|
||||||
if dstStart.After(srcStart) {
|
if dstStart.After(srcStart) {
|
||||||
advance := dstStart.Sub(srcStart) / srcInterval
|
advance := int(dstStart.Sub(srcStart) / srcInterval)
|
||||||
srcIndex += int(advance)
|
srcIndex += advance
|
||||||
srcStart = srcStart.Add(advance * srcInterval)
|
srcStart = srcStart.Add(time.Duration(advance) * srcInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The i'th value is computed as show below.
|
// The i'th value is computed as show below.
|
||||||
|
|
|
@ -35,6 +35,7 @@ func marshalInterface(b []byte, cm *ControlMessage) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseInterface(cm *ControlMessage, b []byte) {
|
func parseInterface(cm *ControlMessage, b []byte) {
|
||||||
sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0]))
|
var sadl syscall.SockaddrDatalink
|
||||||
|
copy((*[unsafe.Sizeof(sadl)]byte)(unsafe.Pointer(&sadl))[:], b)
|
||||||
cm.IfIndex = int(sadl.Index)
|
cm.IfIndex = int(sadl.Index)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
const (
|
const (
|
||||||
Version = 4 // protocol version
|
Version = 4 // protocol version
|
||||||
HeaderLen = 20 // header length without extension headers
|
HeaderLen = 20 // header length without extension headers
|
||||||
maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HeaderFlags int
|
type HeaderFlags int
|
||||||
|
|
|
@ -15,13 +15,10 @@ import (
|
||||||
var (
|
var (
|
||||||
errInvalidConn = errors.New("invalid connection")
|
errInvalidConn = errors.New("invalid connection")
|
||||||
errMissingAddress = errors.New("missing address")
|
errMissingAddress = errors.New("missing address")
|
||||||
errMissingHeader = errors.New("missing header")
|
|
||||||
errNilHeader = errors.New("nil header")
|
errNilHeader = errors.New("nil header")
|
||||||
errHeaderTooShort = errors.New("header too short")
|
errHeaderTooShort = errors.New("header too short")
|
||||||
errExtHeaderTooShort = errors.New("extension header too short")
|
errExtHeaderTooShort = errors.New("extension header too short")
|
||||||
errInvalidConnType = errors.New("invalid conn type")
|
errInvalidConnType = errors.New("invalid conn type")
|
||||||
errNoSuchInterface = errors.New("no such interface")
|
|
||||||
errNoSuchMulticastInterface = errors.New("no such multicast interface")
|
|
||||||
errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
|
errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
|
||||||
|
|
||||||
// See https://www.freebsd.org/doc/en/books/porters-handbook/versions.html.
|
// See https://www.freebsd.org/doc/en/books/porters-handbook/versions.html.
|
||||||
|
|
|
@ -7,12 +7,15 @@
|
||||||
package ipv4
|
package ipv4
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"golang.org/x/net/internal/socket"
|
"golang.org/x/net/internal/socket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errNoSuchInterface = errors.New("no such interface")
|
||||||
|
|
||||||
func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
|
func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
|
||||||
mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
|
mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
|
||||||
if err := setIPMreqInterface(&mreq, ifi); err != nil {
|
if err := setIPMreqInterface(&mreq, ifi); err != nil {
|
||||||
|
|
|
@ -11,13 +11,14 @@ import (
|
||||||
|
|
||||||
"golang.org/x/net/bpf"
|
"golang.org/x/net/bpf"
|
||||||
"golang.org/x/net/internal/socket"
|
"golang.org/x/net/internal/socket"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error {
|
func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error {
|
||||||
prog := sockFProg{
|
prog := unix.SockFprog{
|
||||||
Len: uint16(len(f)),
|
Len: uint16(len(f)),
|
||||||
Filter: (*sockFilter)(unsafe.Pointer(&f[0])),
|
Filter: (*unix.SockFilter)(unsafe.Pointer(&f[0])),
|
||||||
}
|
}
|
||||||
b := (*[sizeofSockFprog]byte)(unsafe.Pointer(&prog))[:sizeofSockFprog]
|
b := (*[unix.SizeofSockFprog]byte)(unsafe.Pointer(&prog))[:unix.SizeofSockFprog]
|
||||||
return so.Set(c, b)
|
return so.Set(c, b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
"golang.org/x/net/internal/iana"
|
"golang.org/x/net/internal/iana"
|
||||||
"golang.org/x/net/internal/socket"
|
"golang.org/x/net/internal/socket"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -35,7 +36,7 @@ var (
|
||||||
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoAttachFilter: {Option: socket.Option{Level: sysSOL_SOCKET, Name: sysSO_ATTACH_FILTER, Len: sizeofSockFprog}},
|
ssoAttachFilter: {Option: socket.Option{Level: unix.SOL_SOCKET, Name: unix.SO_ATTACH_FILTER, Len: unix.SizeofSockFprog}},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
|
package ipv4
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysIP_OPTIONS = 0x1
|
||||||
|
sysIP_HDRINCL = 0x2
|
||||||
|
sysIP_TOS = 0x3
|
||||||
|
sysIP_TTL = 0x4
|
||||||
|
sysIP_RECVOPTS = 0x5
|
||||||
|
sysIP_RECVRETOPTS = 0x6
|
||||||
|
sysIP_RECVDSTADDR = 0x7
|
||||||
|
sysIP_SENDSRCADDR = 0x7
|
||||||
|
sysIP_RETOPTS = 0x8
|
||||||
|
sysIP_RECVIF = 0x14
|
||||||
|
sysIP_ONESBCAST = 0x17
|
||||||
|
sysIP_BINDANY = 0x18
|
||||||
|
sysIP_RECVTTL = 0x41
|
||||||
|
sysIP_MINTTL = 0x42
|
||||||
|
sysIP_DONTFRAG = 0x43
|
||||||
|
sysIP_RECVTOS = 0x44
|
||||||
|
|
||||||
|
sysIP_MULTICAST_IF = 0x9
|
||||||
|
sysIP_MULTICAST_TTL = 0xa
|
||||||
|
sysIP_MULTICAST_LOOP = 0xb
|
||||||
|
sysIP_ADD_MEMBERSHIP = 0xc
|
||||||
|
sysIP_DROP_MEMBERSHIP = 0xd
|
||||||
|
sysIP_MULTICAST_VIF = 0xe
|
||||||
|
sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
|
||||||
|
sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
|
||||||
|
sysIP_BLOCK_SOURCE = 0x48
|
||||||
|
sysIP_UNBLOCK_SOURCE = 0x49
|
||||||
|
sysMCAST_JOIN_GROUP = 0x50
|
||||||
|
sysMCAST_LEAVE_GROUP = 0x51
|
||||||
|
sysMCAST_JOIN_SOURCE_GROUP = 0x52
|
||||||
|
sysMCAST_LEAVE_SOURCE_GROUP = 0x53
|
||||||
|
sysMCAST_BLOCK_SOURCE = 0x54
|
||||||
|
sysMCAST_UNBLOCK_SOURCE = 0x55
|
||||||
|
|
||||||
|
sizeofSockaddrStorage = 0x80
|
||||||
|
sizeofSockaddrInet = 0x10
|
||||||
|
|
||||||
|
sizeofIPMreq = 0x8
|
||||||
|
sizeofIPMreqn = 0xc
|
||||||
|
sizeofIPMreqSource = 0xc
|
||||||
|
sizeofGroupReq = 0x88
|
||||||
|
sizeofGroupSourceReq = 0x108
|
||||||
|
)
|
||||||
|
|
||||||
|
type sockaddrStorage struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
X__ss_pad1 [6]uint8
|
||||||
|
X__ss_align int64
|
||||||
|
X__ss_pad2 [112]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Addr [4]byte /* in_addr */
|
||||||
|
Zero [8]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type ipMreq struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Interface [4]byte /* in_addr */
|
||||||
|
}
|
||||||
|
|
||||||
|
type ipMreqn struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Address [4]byte /* in_addr */
|
||||||
|
Ifindex int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ipMreqSource struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Sourceaddr [4]byte /* in_addr */
|
||||||
|
Interface [4]byte /* in_addr */
|
||||||
|
}
|
||||||
|
|
||||||
|
type groupReq struct {
|
||||||
|
Interface uint32
|
||||||
|
Group sockaddrStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
type groupSourceReq struct {
|
||||||
|
Interface uint32
|
||||||
|
Group sockaddrStorage
|
||||||
|
Source sockaddrStorage
|
||||||
|
}
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -133,16 +128,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -133,16 +128,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -133,16 +128,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -133,16 +128,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -133,16 +128,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -57,9 +57,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -72,8 +69,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -137,15 +132,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ const (
|
||||||
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
sysSO_EE_ORIGIN_TXSTATUS = 0x4
|
||||||
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
sizeofInetPktinfo = 0xc
|
sizeofInetPktinfo = 0xc
|
||||||
|
@ -70,8 +67,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPFilter = 0x4
|
sizeofICMPFilter = 0x4
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -135,16 +130,3 @@ type groupSourceReq struct {
|
||||||
type icmpFilter struct {
|
type icmpFilter struct {
|
||||||
Data uint32
|
Data uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ var (
|
||||||
errMissingAddress = errors.New("missing address")
|
errMissingAddress = errors.New("missing address")
|
||||||
errHeaderTooShort = errors.New("header too short")
|
errHeaderTooShort = errors.New("header too short")
|
||||||
errInvalidConnType = errors.New("invalid conn type")
|
errInvalidConnType = errors.New("invalid conn type")
|
||||||
errNoSuchInterface = errors.New("no such interface")
|
|
||||||
errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
|
errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,14 @@ import (
|
||||||
|
|
||||||
"golang.org/x/net/bpf"
|
"golang.org/x/net/bpf"
|
||||||
"golang.org/x/net/internal/socket"
|
"golang.org/x/net/internal/socket"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error {
|
func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error {
|
||||||
prog := sockFProg{
|
prog := unix.SockFprog{
|
||||||
Len: uint16(len(f)),
|
Len: uint16(len(f)),
|
||||||
Filter: (*sockFilter)(unsafe.Pointer(&f[0])),
|
Filter: (*unix.SockFilter)(unsafe.Pointer(&f[0])),
|
||||||
}
|
}
|
||||||
b := (*[sizeofSockFprog]byte)(unsafe.Pointer(&prog))[:sizeofSockFprog]
|
b := (*[unix.SizeofSockFprog]byte)(unsafe.Pointer(&prog))[:unix.SizeofSockFprog]
|
||||||
return so.Set(c, b)
|
return so.Set(c, b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
"golang.org/x/net/internal/iana"
|
"golang.org/x/net/internal/iana"
|
||||||
"golang.org/x/net/internal/socket"
|
"golang.org/x/net/internal/socket"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -40,7 +41,7 @@ var (
|
||||||
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
||||||
ssoAttachFilter: {Option: socket.Option{Level: sysSOL_SOCKET, Name: sysSO_ATTACH_FILTER, Len: sizeofSockFprog}},
|
ssoAttachFilter: {Option: socket.Option{Level: unix.SOL_SOCKET, Name: unix.SO_ATTACH_FILTER, Len: unix.SizeofSockFprog}},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
|
package ipv6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysIPV6_UNICAST_HOPS = 0x4
|
||||||
|
sysIPV6_MULTICAST_IF = 0x9
|
||||||
|
sysIPV6_MULTICAST_HOPS = 0xa
|
||||||
|
sysIPV6_MULTICAST_LOOP = 0xb
|
||||||
|
sysIPV6_JOIN_GROUP = 0xc
|
||||||
|
sysIPV6_LEAVE_GROUP = 0xd
|
||||||
|
sysIPV6_PORTRANGE = 0xe
|
||||||
|
sysICMP6_FILTER = 0x12
|
||||||
|
|
||||||
|
sysIPV6_CHECKSUM = 0x1a
|
||||||
|
sysIPV6_V6ONLY = 0x1b
|
||||||
|
|
||||||
|
sysIPV6_IPSEC_POLICY = 0x1c
|
||||||
|
|
||||||
|
sysIPV6_RTHDRDSTOPTS = 0x23
|
||||||
|
|
||||||
|
sysIPV6_RECVPKTINFO = 0x24
|
||||||
|
sysIPV6_RECVHOPLIMIT = 0x25
|
||||||
|
sysIPV6_RECVRTHDR = 0x26
|
||||||
|
sysIPV6_RECVHOPOPTS = 0x27
|
||||||
|
sysIPV6_RECVDSTOPTS = 0x28
|
||||||
|
|
||||||
|
sysIPV6_USE_MIN_MTU = 0x2a
|
||||||
|
sysIPV6_RECVPATHMTU = 0x2b
|
||||||
|
|
||||||
|
sysIPV6_PATHMTU = 0x2c
|
||||||
|
|
||||||
|
sysIPV6_PKTINFO = 0x2e
|
||||||
|
sysIPV6_HOPLIMIT = 0x2f
|
||||||
|
sysIPV6_NEXTHOP = 0x30
|
||||||
|
sysIPV6_HOPOPTS = 0x31
|
||||||
|
sysIPV6_DSTOPTS = 0x32
|
||||||
|
sysIPV6_RTHDR = 0x33
|
||||||
|
|
||||||
|
sysIPV6_RECVTCLASS = 0x39
|
||||||
|
|
||||||
|
sysIPV6_AUTOFLOWLABEL = 0x3b
|
||||||
|
|
||||||
|
sysIPV6_TCLASS = 0x3d
|
||||||
|
sysIPV6_DONTFRAG = 0x3e
|
||||||
|
|
||||||
|
sysIPV6_PREFER_TEMPADDR = 0x3f
|
||||||
|
|
||||||
|
sysIPV6_BINDANY = 0x40
|
||||||
|
|
||||||
|
sysIPV6_MSFILTER = 0x4a
|
||||||
|
|
||||||
|
sysMCAST_JOIN_GROUP = 0x50
|
||||||
|
sysMCAST_LEAVE_GROUP = 0x51
|
||||||
|
sysMCAST_JOIN_SOURCE_GROUP = 0x52
|
||||||
|
sysMCAST_LEAVE_SOURCE_GROUP = 0x53
|
||||||
|
sysMCAST_BLOCK_SOURCE = 0x54
|
||||||
|
sysMCAST_UNBLOCK_SOURCE = 0x55
|
||||||
|
|
||||||
|
sysIPV6_PORTRANGE_DEFAULT = 0x0
|
||||||
|
sysIPV6_PORTRANGE_HIGH = 0x1
|
||||||
|
sysIPV6_PORTRANGE_LOW = 0x2
|
||||||
|
|
||||||
|
sizeofSockaddrStorage = 0x80
|
||||||
|
sizeofSockaddrInet6 = 0x1c
|
||||||
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
sizeofIPv6Mtuinfo = 0x20
|
||||||
|
|
||||||
|
sizeofIPv6Mreq = 0x14
|
||||||
|
sizeofGroupReq = 0x88
|
||||||
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
|
sizeofICMPv6Filter = 0x20
|
||||||
|
)
|
||||||
|
|
||||||
|
type sockaddrStorage struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
X__ss_pad1 [6]uint8
|
||||||
|
X__ss_align int64
|
||||||
|
X__ss_pad2 [112]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet6 struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Flowinfo uint32
|
||||||
|
Addr [16]byte /* in6_addr */
|
||||||
|
Scope_id uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type inet6Pktinfo struct {
|
||||||
|
Addr [16]byte /* in6_addr */
|
||||||
|
Ifindex uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ipv6Mtuinfo struct {
|
||||||
|
Addr sockaddrInet6
|
||||||
|
Mtu uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ipv6Mreq struct {
|
||||||
|
Multiaddr [16]byte /* in6_addr */
|
||||||
|
Interface uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type groupReq struct {
|
||||||
|
Interface uint32
|
||||||
|
Group sockaddrStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
type groupSourceReq struct {
|
||||||
|
Interface uint32
|
||||||
|
Group sockaddrStorage
|
||||||
|
Source sockaddrStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
type icmpv6Filter struct {
|
||||||
|
Filt [8]uint32
|
||||||
|
}
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -155,16 +150,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -155,16 +150,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -155,16 +150,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -155,16 +150,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x104
|
sizeofGroupSourceReq = 0x104
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -155,16 +150,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [2]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -86,9 +86,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -100,8 +97,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -159,15 +154,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ const (
|
||||||
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
sysICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
sysICMPV6_FILTER_PASSONLY = 0x4
|
sysICMPV6_FILTER_PASSONLY = 0x4
|
||||||
|
|
||||||
sysSOL_SOCKET = 0x1
|
|
||||||
sysSO_ATTACH_FILTER = 0x1a
|
|
||||||
|
|
||||||
sizeofKernelSockaddrStorage = 0x80
|
sizeofKernelSockaddrStorage = 0x80
|
||||||
sizeofSockaddrInet6 = 0x1c
|
sizeofSockaddrInet6 = 0x1c
|
||||||
sizeofInet6Pktinfo = 0x14
|
sizeofInet6Pktinfo = 0x14
|
||||||
|
@ -98,8 +95,6 @@ const (
|
||||||
sizeofGroupSourceReq = 0x108
|
sizeofGroupSourceReq = 0x108
|
||||||
|
|
||||||
sizeofICMPv6Filter = 0x20
|
sizeofICMPv6Filter = 0x20
|
||||||
|
|
||||||
sizeofSockFprog = 0x10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type kernelSockaddrStorage struct {
|
type kernelSockaddrStorage struct {
|
||||||
|
@ -157,16 +152,3 @@ type groupSourceReq struct {
|
||||||
type icmpv6Filter struct {
|
type icmpv6Filter struct {
|
||||||
Data [8]uint32
|
Data [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type sockFProg struct {
|
|
||||||
Len uint16
|
|
||||||
Pad_cgo_0 [6]byte
|
|
||||||
Filter *sockFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
type sockFilter struct {
|
|
||||||
Code uint16
|
|
||||||
Jt uint8
|
|
||||||
Jf uint8
|
|
||||||
K uint32
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,20 +39,25 @@ func (bigEndian) Uint64(b []byte) uint64 {
|
||||||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
||||||
}
|
}
|
||||||
|
|
||||||
// hostByteOrder returns binary.LittleEndian on little-endian machines and
|
// hostByteOrder returns littleEndian on little-endian machines and
|
||||||
// binary.BigEndian on big-endian machines.
|
// bigEndian on big-endian machines.
|
||||||
func hostByteOrder() byteOrder {
|
func hostByteOrder() byteOrder {
|
||||||
switch runtime.GOARCH {
|
switch runtime.GOARCH {
|
||||||
case "386", "amd64", "amd64p32",
|
case "386", "amd64", "amd64p32",
|
||||||
|
"alpha",
|
||||||
"arm", "arm64",
|
"arm", "arm64",
|
||||||
"mipsle", "mips64le", "mips64p32le",
|
"mipsle", "mips64le", "mips64p32le",
|
||||||
|
"nios2",
|
||||||
"ppc64le",
|
"ppc64le",
|
||||||
"riscv", "riscv64":
|
"riscv", "riscv64",
|
||||||
|
"sh":
|
||||||
return littleEndian{}
|
return littleEndian{}
|
||||||
case "armbe", "arm64be",
|
case "armbe", "arm64be",
|
||||||
|
"m68k",
|
||||||
"mips", "mips64", "mips64p32",
|
"mips", "mips64", "mips64p32",
|
||||||
"ppc", "ppc64",
|
"ppc", "ppc64",
|
||||||
"s390", "s390x",
|
"s390", "s390x",
|
||||||
|
"shbe",
|
||||||
"sparc", "sparc64":
|
"sparc", "sparc64":
|
||||||
return bigEndian{}
|
return bigEndian{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,15 @@ var ARM struct {
|
||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MIPS64X contains the supported CPU features of the current mips64/mips64le
|
||||||
|
// platforms. If the current platform is not mips64/mips64le or the current
|
||||||
|
// operating system is not Linux then all feature flags are false.
|
||||||
|
var MIPS64X struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasMSA bool // MIPS SIMD architecture
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
// PPC64 contains the supported CPU features of the current ppc64/ppc64le platforms.
|
// PPC64 contains the supported CPU features of the current ppc64/ppc64le platforms.
|
||||||
// If the current platform is not ppc64/ppc64le then all feature flags are false.
|
// If the current platform is not ppc64/ppc64le then all feature flags are false.
|
||||||
//
|
//
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build aix,ppc64
|
// +build aix
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
// Copyright 2019 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 cpu
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
const cacheLineSize = 64
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "android", "darwin", "netbsd":
|
||||||
|
// Android and iOS don't seem to allow reading these registers.
|
||||||
|
//
|
||||||
|
// NetBSD:
|
||||||
|
// ID_AA64ISAR0_EL1 is a privileged register and cannot be read from EL0.
|
||||||
|
// It can be read via sysctl(3). Example for future implementers:
|
||||||
|
// https://nxr.netbsd.org/xref/src/usr.sbin/cpuctl/arch/aarch64.c
|
||||||
|
//
|
||||||
|
// Fake the minimal features expected by
|
||||||
|
// TestARM64minimalFeatures.
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
ARM64.HasFP = true
|
||||||
|
case "linux":
|
||||||
|
doinit()
|
||||||
|
default:
|
||||||
|
readARM64Registers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readARM64Registers() {
|
||||||
|
Initialized = true
|
||||||
|
|
||||||
|
// ID_AA64ISAR0_EL1
|
||||||
|
isar0 := getisar0()
|
||||||
|
|
||||||
|
switch extractBits(isar0, 4, 7) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasAES = true
|
||||||
|
case 2:
|
||||||
|
ARM64.HasAES = true
|
||||||
|
ARM64.HasPMULL = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 8, 11) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA1 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 12, 15) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA2 = true
|
||||||
|
case 2:
|
||||||
|
ARM64.HasSHA2 = true
|
||||||
|
ARM64.HasSHA512 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 16, 19) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasCRC32 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 20, 23) {
|
||||||
|
case 2:
|
||||||
|
ARM64.HasATOMICS = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 28, 31) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMDRDM = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 32, 35) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA3 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 36, 39) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSM3 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 40, 43) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSM4 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 44, 47) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMDDP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID_AA64ISAR1_EL1
|
||||||
|
isar1 := getisar1()
|
||||||
|
|
||||||
|
switch extractBits(isar1, 0, 3) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasDCPOP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 12, 15) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasJSCVT = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 16, 19) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasFCMA = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 20, 23) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasLRCPC = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID_AA64PFR0_EL1
|
||||||
|
pfr0 := getpfr0()
|
||||||
|
|
||||||
|
switch extractBits(pfr0, 16, 19) {
|
||||||
|
case 0:
|
||||||
|
ARM64.HasFP = true
|
||||||
|
case 1:
|
||||||
|
ARM64.HasFP = true
|
||||||
|
ARM64.HasFPHP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(pfr0, 20, 23) {
|
||||||
|
case 0:
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
ARM64.HasASIMDHP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(pfr0, 32, 35) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSVE = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractBits(data uint64, start, end uint) uint {
|
||||||
|
return (uint)(data>>start) & ((1 << (end - start + 1)) - 1)
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright 2019 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 !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func getisar0() uint64
|
||||||
|
TEXT ·getisar0(SB),NOSPLIT,$0-8
|
||||||
|
// get Instruction Set Attributes 0 into x0
|
||||||
|
// mrs x0, ID_AA64ISAR0_EL1 = d5380600
|
||||||
|
WORD $0xd5380600
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func getisar1() uint64
|
||||||
|
TEXT ·getisar1(SB),NOSPLIT,$0-8
|
||||||
|
// get Instruction Set Attributes 1 into x0
|
||||||
|
// mrs x0, ID_AA64ISAR1_EL1 = d5380620
|
||||||
|
WORD $0xd5380620
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func getpfr0() uint64
|
||||||
|
TEXT ·getpfr0(SB),NOSPLIT,$0-8
|
||||||
|
// get Processor Feature Register 0 into x0
|
||||||
|
// mrs x0, ID_AA64PFR0_EL1 = d5380400
|
||||||
|
WORD $0xd5380400
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2019 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 !gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func getisar0() uint64
|
||||||
|
func getisar1() uint64
|
||||||
|
func getpfr0() uint64
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2019 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 gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func getisar0() uint64 { return 0 }
|
||||||
|
func getisar1() uint64 { return 0 }
|
||||||
|
func getpfr0() uint64 { return 0 }
|
|
@ -2,58 +2,14 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !amd64,!amd64p32,!386
|
// +build !386,!amd64,!amd64p32,!arm64
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
_AT_HWCAP = 16
|
|
||||||
_AT_HWCAP2 = 26
|
|
||||||
|
|
||||||
procAuxv = "/proc/self/auxv"
|
|
||||||
|
|
||||||
uintSize = int(32 << (^uint(0) >> 63))
|
|
||||||
)
|
|
||||||
|
|
||||||
// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
|
|
||||||
// These are initialized in cpu_$GOARCH.go
|
|
||||||
// and should not be changed after they are initialized.
|
|
||||||
var hwCap uint
|
|
||||||
var hwCap2 uint
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
buf, err := ioutil.ReadFile(procAuxv)
|
if err := readHWCAP(); err != nil {
|
||||||
if err != nil {
|
|
||||||
// e.g. on android /proc/self/auxv is not accessible, so silently
|
|
||||||
// ignore the error and leave Initialized = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
bo := hostByteOrder()
|
|
||||||
for len(buf) >= 2*(uintSize/8) {
|
|
||||||
var tag, val uint
|
|
||||||
switch uintSize {
|
|
||||||
case 32:
|
|
||||||
tag = uint(bo.Uint32(buf[0:]))
|
|
||||||
val = uint(bo.Uint32(buf[4:]))
|
|
||||||
buf = buf[8:]
|
|
||||||
case 64:
|
|
||||||
tag = uint(bo.Uint64(buf[0:]))
|
|
||||||
val = uint(bo.Uint64(buf[8:]))
|
|
||||||
buf = buf[16:]
|
|
||||||
}
|
|
||||||
switch tag {
|
|
||||||
case _AT_HWCAP:
|
|
||||||
hwCap = val
|
|
||||||
case _AT_HWCAP2:
|
|
||||||
hwCap2 = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
doinit()
|
doinit()
|
||||||
|
|
||||||
Initialized = true
|
Initialized = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
const cacheLineSize = 64
|
|
||||||
|
|
||||||
// HWCAP/HWCAP2 bits. These are exposed by Linux.
|
// HWCAP/HWCAP2 bits. These are exposed by Linux.
|
||||||
const (
|
const (
|
||||||
hwcap_FP = 1 << 0
|
hwcap_FP = 1 << 0
|
||||||
|
@ -35,6 +33,12 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func doinit() {
|
func doinit() {
|
||||||
|
if err := readHWCAP(); err != nil {
|
||||||
|
// failed to read /proc/self/auxv, try reading registers directly
|
||||||
|
readARM64Registers()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// HWCAP feature bits
|
// HWCAP feature bits
|
||||||
ARM64.HasFP = isSet(hwCap, hwcap_FP)
|
ARM64.HasFP = isSet(hwCap, hwcap_FP)
|
||||||
ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
|
ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2020 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 mips64 mips64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// HWCAP bits. These are exposed by the Linux kernel 5.4.
|
||||||
|
const (
|
||||||
|
// CPU features
|
||||||
|
hwcap_MIPS_MSA = 1 << 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
// HWCAP feature bits
|
||||||
|
MIPS64X.HasMSA = isSet(hwCap, hwcap_MIPS_MSA)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2019 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 linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func doinit() {}
|
|
@ -7,5 +7,3 @@
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
const cacheLineSize = 32
|
const cacheLineSize = 32
|
||||||
|
|
||||||
func doinit() {}
|
|
||||||
|
|
|
@ -7,5 +7,3 @@
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
const cacheLineSize = 32
|
const cacheLineSize = 32
|
||||||
|
|
||||||
func doinit() {}
|
|
||||||
|
|
|
@ -6,6 +6,4 @@
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
const cacheLineSize = 64
|
|
||||||
|
|
||||||
func doinit() {}
|
func doinit() {}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2019 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 riscv64
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 32
|
|
@ -11,5 +11,3 @@ package cpu
|
||||||
// rules are good enough.
|
// rules are good enough.
|
||||||
|
|
||||||
const cacheLineSize = 0
|
const cacheLineSize = 0
|
||||||
|
|
||||||
func doinit() {}
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright 2019 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 cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
_AT_HWCAP = 16
|
||||||
|
_AT_HWCAP2 = 26
|
||||||
|
|
||||||
|
procAuxv = "/proc/self/auxv"
|
||||||
|
|
||||||
|
uintSize = int(32 << (^uint(0) >> 63))
|
||||||
|
)
|
||||||
|
|
||||||
|
// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
|
||||||
|
// These are initialized in cpu_$GOARCH.go
|
||||||
|
// and should not be changed after they are initialized.
|
||||||
|
var hwCap uint
|
||||||
|
var hwCap2 uint
|
||||||
|
|
||||||
|
func readHWCAP() error {
|
||||||
|
buf, err := ioutil.ReadFile(procAuxv)
|
||||||
|
if err != nil {
|
||||||
|
// e.g. on android /proc/self/auxv is not accessible, so silently
|
||||||
|
// ignore the error and leave Initialized = false. On some
|
||||||
|
// architectures (e.g. arm64) doinit() implements a fallback
|
||||||
|
// readout and will set Initialized = true again.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
bo := hostByteOrder()
|
||||||
|
for len(buf) >= 2*(uintSize/8) {
|
||||||
|
var tag, val uint
|
||||||
|
switch uintSize {
|
||||||
|
case 32:
|
||||||
|
tag = uint(bo.Uint32(buf[0:]))
|
||||||
|
val = uint(bo.Uint32(buf[4:]))
|
||||||
|
buf = buf[8:]
|
||||||
|
case 64:
|
||||||
|
tag = uint(bo.Uint64(buf[0:]))
|
||||||
|
val = uint(bo.Uint64(buf[8:]))
|
||||||
|
buf = buf[16:]
|
||||||
|
}
|
||||||
|
switch tag {
|
||||||
|
case _AT_HWCAP:
|
||||||
|
hwCap = val
|
||||||
|
case _AT_HWCAP2:
|
||||||
|
hwCap2 = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
// Recreate a getsystemcfg syscall handler instead of
|
||||||
|
// using the one provided by x/sys/unix to avoid having
|
||||||
|
// the dependency between them. (See golang.org/issue/32102)
|
||||||
|
// Morever, this file will be used during the building of
|
||||||
|
// gccgo's libgo and thus must not used a CGo method.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
//extern getsystemcfg
|
||||||
|
func gccgoGetsystemcfg(label uint32) (r uint64)
|
||||||
|
|
||||||
|
func callgetsystemcfg(label int) (r1 uintptr, e1 syscall.Errno) {
|
||||||
|
r1 = uintptr(gccgoGetsystemcfg(uint32(label)))
|
||||||
|
e1 = syscall.GetErrno()
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2020 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 unsafeheader contains header declarations for the Go runtime's
|
||||||
|
// slice and string implementations.
|
||||||
|
//
|
||||||
|
// This package allows x/sys to use types equivalent to
|
||||||
|
// reflect.SliceHeader and reflect.StringHeader without introducing
|
||||||
|
// a dependency on the (relatively heavy) "reflect" package.
|
||||||
|
package unsafeheader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice is the runtime representation of a slice.
|
||||||
|
// It cannot be used safely or portably and its representation may change in a later release.
|
||||||
|
type Slice struct {
|
||||||
|
Data unsafe.Pointer
|
||||||
|
Len int
|
||||||
|
Cap int
|
||||||
|
}
|
||||||
|
|
||||||
|
// String is the runtime representation of a string.
|
||||||
|
// It cannot be used safely or portably and its representation may change in a later release.
|
||||||
|
type String struct {
|
||||||
|
Data unsafe.Pointer
|
||||||
|
Len int
|
||||||
|
}
|
|
@ -89,7 +89,7 @@ constants.
|
||||||
|
|
||||||
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
||||||
new installation of the target OS (or updating the source checkouts for the
|
new installation of the target OS (or updating the source checkouts for the
|
||||||
new build system). However, depending on the OS, you make need to update the
|
new build system). However, depending on the OS, you may need to update the
|
||||||
parsing in mksysnum.
|
parsing in mksysnum.
|
||||||
|
|
||||||
### mksyscall.go
|
### mksyscall.go
|
||||||
|
@ -149,10 +149,21 @@ To add a constant, add the header that includes it to the appropriate variable.
|
||||||
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
||||||
the regex too broad to avoid matching unintended constants.
|
the regex too broad to avoid matching unintended constants.
|
||||||
|
|
||||||
|
### mkmerge.go
|
||||||
|
|
||||||
|
This program is used to extract duplicate const, func, and type declarations
|
||||||
|
from the generated architecture-specific files listed below, and merge these
|
||||||
|
into a common file for each OS.
|
||||||
|
|
||||||
|
The merge is performed in the following steps:
|
||||||
|
1. Construct the set of common code that is idential in all architecture-specific files.
|
||||||
|
2. Write this common code to the merged file.
|
||||||
|
3. Remove the common code from all architecture-specific files.
|
||||||
|
|
||||||
|
|
||||||
## Generated files
|
## Generated files
|
||||||
|
|
||||||
### `zerror_${GOOS}_${GOARCH}.go`
|
### `zerrors_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
A file containing all of the system's generated error numbers, error strings,
|
A file containing all of the system's generated error numbers, error strings,
|
||||||
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
||||||
|
|
|
@ -23,10 +23,6 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
MOV a1+8(FP), A0
|
MOV a1+8(FP), A0
|
||||||
MOV a2+16(FP), A1
|
MOV a2+16(FP), A1
|
||||||
MOV a3+24(FP), A2
|
MOV a3+24(FP), A2
|
||||||
MOV $0, A3
|
|
||||||
MOV $0, A4
|
|
||||||
MOV $0, A5
|
|
||||||
MOV $0, A6
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
ECALL
|
ECALL
|
||||||
MOV A0, r1+32(FP) // r1
|
MOV A0, r1+32(FP) // r1
|
||||||
|
@ -44,9 +40,6 @@ TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
MOV a1+8(FP), A0
|
MOV a1+8(FP), A0
|
||||||
MOV a2+16(FP), A1
|
MOV a2+16(FP), A1
|
||||||
MOV a3+24(FP), A2
|
MOV a3+24(FP), A2
|
||||||
MOV ZERO, A3
|
|
||||||
MOV ZERO, A4
|
|
||||||
MOV ZERO, A5
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
ECALL
|
ECALL
|
||||||
MOV A0, r1+32(FP)
|
MOV A0, r1+32(FP)
|
||||||
|
|
|
@ -23,6 +23,7 @@ const (
|
||||||
HCI_CHANNEL_USER = 1
|
HCI_CHANNEL_USER = 1
|
||||||
HCI_CHANNEL_MONITOR = 2
|
HCI_CHANNEL_MONITOR = 2
|
||||||
HCI_CHANNEL_CONTROL = 3
|
HCI_CHANNEL_CONTROL = 3
|
||||||
|
HCI_CHANNEL_LOGGING = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// Socketoption Level
|
// Socketoption Level
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
DLT_HHDLC = 0x79
|
||||||
IFF_SMART = 0x20
|
IFF_SMART = 0x20
|
||||||
IFT_1822 = 0x2
|
IFT_1822 = 0x2
|
||||||
IFT_A12MPPSWITCH = 0x82
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
@ -210,13 +211,18 @@ const (
|
||||||
IFT_XETHER = 0x1a
|
IFT_XETHER = 0x1a
|
||||||
IPPROTO_MAXID = 0x34
|
IPPROTO_MAXID = 0x34
|
||||||
IPV6_FAITH = 0x1d
|
IPV6_FAITH = 0x1d
|
||||||
|
IPV6_MIN_MEMBERSHIPS = 0x1f
|
||||||
IP_FAITH = 0x16
|
IP_FAITH = 0x16
|
||||||
|
IP_MAX_SOURCE_FILTER = 0x400
|
||||||
|
IP_MIN_MEMBERSHIPS = 0x1f
|
||||||
MAP_NORESERVE = 0x40
|
MAP_NORESERVE = 0x40
|
||||||
MAP_RENAME = 0x20
|
MAP_RENAME = 0x20
|
||||||
NET_RT_MAXID = 0x6
|
NET_RT_MAXID = 0x6
|
||||||
RTF_PRCLONING = 0x10000
|
RTF_PRCLONING = 0x10000
|
||||||
RTM_OLDADD = 0x9
|
RTM_OLDADD = 0x9
|
||||||
RTM_OLDDEL = 0xa
|
RTM_OLDDEL = 0xa
|
||||||
|
RT_CACHING_CONTEXT = 0x1
|
||||||
|
RT_NORTREF = 0x2
|
||||||
SIOCADDRT = 0x8030720a
|
SIOCADDRT = 0x8030720a
|
||||||
SIOCALIFADDR = 0x8118691b
|
SIOCALIFADDR = 0x8118691b
|
||||||
SIOCDELRT = 0x8030720b
|
SIOCDELRT = 0x8030720b
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
DLT_HHDLC = 0x79
|
||||||
IFF_SMART = 0x20
|
IFF_SMART = 0x20
|
||||||
IFT_1822 = 0x2
|
IFT_1822 = 0x2
|
||||||
IFT_A12MPPSWITCH = 0x82
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
@ -210,13 +211,18 @@ const (
|
||||||
IFT_XETHER = 0x1a
|
IFT_XETHER = 0x1a
|
||||||
IPPROTO_MAXID = 0x34
|
IPPROTO_MAXID = 0x34
|
||||||
IPV6_FAITH = 0x1d
|
IPV6_FAITH = 0x1d
|
||||||
|
IPV6_MIN_MEMBERSHIPS = 0x1f
|
||||||
IP_FAITH = 0x16
|
IP_FAITH = 0x16
|
||||||
|
IP_MAX_SOURCE_FILTER = 0x400
|
||||||
|
IP_MIN_MEMBERSHIPS = 0x1f
|
||||||
MAP_NORESERVE = 0x40
|
MAP_NORESERVE = 0x40
|
||||||
MAP_RENAME = 0x20
|
MAP_RENAME = 0x20
|
||||||
NET_RT_MAXID = 0x6
|
NET_RT_MAXID = 0x6
|
||||||
RTF_PRCLONING = 0x10000
|
RTF_PRCLONING = 0x10000
|
||||||
RTM_OLDADD = 0x9
|
RTM_OLDADD = 0x9
|
||||||
RTM_OLDDEL = 0xa
|
RTM_OLDDEL = 0xa
|
||||||
|
RT_CACHING_CONTEXT = 0x1
|
||||||
|
RT_NORTREF = 0x2
|
||||||
SIOCADDRT = 0x8040720a
|
SIOCADDRT = 0x8040720a
|
||||||
SIOCALIFADDR = 0x8118691b
|
SIOCALIFADDR = 0x8118691b
|
||||||
SIOCDELRT = 0x8040720b
|
SIOCDELRT = 0x8040720b
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||||
|
// them here for backwards compatibility.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
DLT_HHDLC = 0x79
|
||||||
|
IPV6_MIN_MEMBERSHIPS = 0x1f
|
||||||
|
IP_MAX_SOURCE_FILTER = 0x400
|
||||||
|
IP_MIN_MEMBERSHIPS = 0x1f
|
||||||
|
RT_CACHING_CONTEXT = 0x1
|
||||||
|
RT_NORTREF = 0x2
|
||||||
|
)
|
|
@ -9,12 +9,11 @@ package unix
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
|
||||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
func fcntl(fd int, cmd, arg int) (int, error) {
|
||||||
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
|
|
||||||
var err error
|
var err error
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
err = errno
|
err = errno
|
||||||
|
@ -22,6 +21,11 @@ func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
return int(valptr), err
|
return int(valptr), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
return fcntl(int(fd), cmd, arg)
|
||||||
|
}
|
||||||
|
|
||||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2019 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Set adds fd to the set fds.
|
||||||
|
func (fds *FdSet) Set(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear removes fd from the set fds.
|
||||||
|
func (fds *FdSet) Clear(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns whether fd is in the set fds.
|
||||||
|
func (fds *FdSet) IsSet(fd int) bool {
|
||||||
|
return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero clears the set fds.
|
||||||
|
func (fds *FdSet) Zero() {
|
||||||
|
for i := range fds.Bits {
|
||||||
|
fds.Bits[i] = 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then
|
||||||
# Use the Docker-based build system
|
# Use the Docker-based build system
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")" && /bin/pwd):/build generate:$GOOS
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ freebsd_arm)
|
||||||
freebsd_arm64)
|
freebsd_arm64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
netbsd_386)
|
netbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
|
@ -190,6 +190,12 @@ solaris_amd64)
|
||||||
mksysnum=
|
mksysnum=
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
|
illumos_amd64)
|
||||||
|
mksyscall="go run mksyscall_solaris.go"
|
||||||
|
mkerrors=
|
||||||
|
mksysnum=
|
||||||
|
mktypes=
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -217,6 +223,11 @@ esac
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
# 1.13 and later, syscalls via libSystem (including syscallPtr)
|
# 1.13 and later, syscalls via libSystem (including syscallPtr)
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
|
||||||
|
elif [ "$GOOS" == "illumos" ]; then
|
||||||
|
# illumos code generation requires a --illumos switch
|
||||||
|
echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
|
||||||
|
# illumos implies solaris, so solaris code generation is also required
|
||||||
|
echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
|
||||||
else
|
else
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -44,6 +44,7 @@ includes_AIX='
|
||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/termio.h>
|
#include <sys/termio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -104,6 +105,7 @@ includes_FreeBSD='
|
||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/disk.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -185,16 +187,21 @@ struct ltchars {
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/timerfd.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
#include <linux/bpf.h>
|
#include <linux/bpf.h>
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
#include <linux/capability.h>
|
#include <linux/capability.h>
|
||||||
#include <linux/cryptouser.h>
|
#include <linux/cryptouser.h>
|
||||||
|
#include <linux/devlink.h>
|
||||||
#include <linux/errqueue.h>
|
#include <linux/errqueue.h>
|
||||||
#include <linux/falloc.h>
|
#include <linux/falloc.h>
|
||||||
#include <linux/fanotify.h>
|
#include <linux/fanotify.h>
|
||||||
#include <linux/filter.h>
|
#include <linux/filter.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#include <linux/fscrypt.h>
|
||||||
|
#include <linux/fsverity.h>
|
||||||
#include <linux/genetlink.h>
|
#include <linux/genetlink.h>
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
#include <linux/icmpv6.h>
|
#include <linux/icmpv6.h>
|
||||||
|
@ -276,6 +283,11 @@ struct ltchars {
|
||||||
// for the tipc_subscr timeout __u32 field.
|
// for the tipc_subscr timeout __u32 field.
|
||||||
#undef TIPC_WAIT_FOREVER
|
#undef TIPC_WAIT_FOREVER
|
||||||
#define TIPC_WAIT_FOREVER 0xffffffff
|
#define TIPC_WAIT_FOREVER 0xffffffff
|
||||||
|
|
||||||
|
// Copied from linux/l2tp.h
|
||||||
|
// Including linux/l2tp.h here causes conflicts between linux/in.h
|
||||||
|
// and netinet/in.h included via net/route.h above.
|
||||||
|
#define IPPROTO_L2TP 115
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
|
@ -469,12 +481,13 @@ ccflags="$@"
|
||||||
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
||||||
$2 ~ /^NS_GET_/ ||
|
$2 ~ /^NS_GET_/ ||
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ ||
|
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ ||
|
||||||
$2 ~ /^KEXEC_/ ||
|
$2 ~ /^KEXEC_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
$2 ~ /^MODULE_INIT_/ ||
|
$2 ~ /^MODULE_INIT_/ ||
|
||||||
$2 !~ "NLA_TYPE_MASK" &&
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
|
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
||||||
$2 ~ /^SIOC/ ||
|
$2 ~ /^SIOC/ ||
|
||||||
$2 ~ /^TIOC/ ||
|
$2 ~ /^TIOC/ ||
|
||||||
|
@ -482,8 +495,9 @@ ccflags="$@"
|
||||||
$2 ~ /^TCSET/ ||
|
$2 ~ /^TCSET/ ||
|
||||||
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
||||||
$2 !~ "RTF_BITS" &&
|
$2 !~ "RTF_BITS" &&
|
||||||
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
$2 ~ /^(IFF|IFT|NET_RT|RTM(GRP)?|RTF|RTV|RTA|RTAX)_/ ||
|
||||||
$2 ~ /^BIOC/ ||
|
$2 ~ /^BIOC/ ||
|
||||||
|
$2 ~ /^DIOC/ ||
|
||||||
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
||||||
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
||||||
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
||||||
|
@ -494,7 +508,10 @@ ccflags="$@"
|
||||||
$2 ~ /^CAN_/ ||
|
$2 ~ /^CAN_/ ||
|
||||||
$2 ~ /^CAP_/ ||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
||||||
|
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ ||
|
||||||
|
$2 ~ /^FS_VERITY_/ ||
|
||||||
|
$2 ~ /^FSCRYPT_/ ||
|
||||||
$2 ~ /^GRND_/ ||
|
$2 ~ /^GRND_/ ||
|
||||||
$2 ~ /^RND/ ||
|
$2 ~ /^RND/ ||
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
|
@ -521,9 +538,11 @@ ccflags="$@"
|
||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
|
$2 ~ /^RWF_/ ||
|
||||||
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
||||||
$2 ~ /^CRYPTO_/ ||
|
$2 ~ /^CRYPTO_/ ||
|
||||||
$2 ~ /^TIPC_/ ||
|
$2 ~ /^TIPC_/ ||
|
||||||
|
$2 ~ /^DEVLINK_/ ||
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
$2 ~/^PPPIOC/ ||
|
$2 ~/^PPPIOC/ ||
|
||||||
|
|
|
@ -510,6 +510,23 @@ func SysctlRaw(name string, args ...int) ([]byte, error) {
|
||||||
return buf[:n], nil
|
return buf[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
||||||
|
mib, err := sysctlmib(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(SizeofClockinfo)
|
||||||
|
var ci Clockinfo
|
||||||
|
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n != SizeofClockinfo {
|
||||||
|
return nil, EIO
|
||||||
|
}
|
||||||
|
return &ci, nil
|
||||||
|
}
|
||||||
|
|
||||||
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
func Utimes(path string, tv []Timeval) error {
|
func Utimes(path string, tv []Timeval) error {
|
||||||
|
@ -577,8 +594,6 @@ func Futimes(fd int, tv []Timeval) error {
|
||||||
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
|
||||||
|
|
||||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||||
|
|
||||||
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import "unsafe"
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/internal/unsafeheader"
|
||||||
|
)
|
||||||
|
|
||||||
//sys closedir(dir uintptr) (err error)
|
//sys closedir(dir uintptr) (err error)
|
||||||
//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
|
//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
|
||||||
|
@ -27,8 +31,6 @@ func libc_fdopendir_trampoline()
|
||||||
|
|
||||||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
// Simulate Getdirentries using fdopendir/readdir_r/closedir.
|
// Simulate Getdirentries using fdopendir/readdir_r/closedir.
|
||||||
const ptrSize = unsafe.Sizeof(uintptr(0))
|
|
||||||
|
|
||||||
// We store the number of entries to skip in the seek
|
// We store the number of entries to skip in the seek
|
||||||
// offset of fd. See issue #31368.
|
// offset of fd. See issue #31368.
|
||||||
// It's not the full required semantics, but should handle the case
|
// It's not the full required semantics, but should handle the case
|
||||||
|
@ -73,6 +75,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
cnt++
|
cnt++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
reclen := int(entry.Reclen)
|
reclen := int(entry.Reclen)
|
||||||
if reclen > len(buf) {
|
if reclen > len(buf) {
|
||||||
// Not enough room. Return for now.
|
// Not enough room. Return for now.
|
||||||
|
@ -81,13 +84,15 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
// restarting is O(n^2) in the length of the directory. Oh well.
|
// restarting is O(n^2) in the length of the directory. Oh well.
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy entry into return buffer.
|
// Copy entry into return buffer.
|
||||||
s := struct {
|
var s []byte
|
||||||
ptr unsafe.Pointer
|
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s))
|
||||||
siz int
|
hdr.Data = unsafe.Pointer(&entry)
|
||||||
cap int
|
hdr.Cap = reclen
|
||||||
}{ptr: unsafe.Pointer(&entry), siz: reclen, cap: reclen}
|
hdr.Len = reclen
|
||||||
copy(buf, *(*[]byte)(unsafe.Pointer(&s)))
|
copy(buf, s)
|
||||||
|
|
||||||
buf = buf[reclen:]
|
buf = buf[reclen:]
|
||||||
n += reclen
|
n += reclen
|
||||||
cnt++
|
cnt++
|
||||||
|
|
|
@ -155,23 +155,6 @@ func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (
|
||||||
|
|
||||||
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
||||||
|
|
||||||
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
|
||||||
mib, err := sysctlmib(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
n := uintptr(SizeofClockinfo)
|
|
||||||
var ci Clockinfo
|
|
||||||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if n != SizeofClockinfo {
|
|
||||||
return nil, EIO
|
|
||||||
}
|
|
||||||
return &ci, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//sysnb pipe() (r int, w int, err error)
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
|
@ -333,12 +316,16 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
|
||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
//sys kill(pid int, signum int, posix int) (err error)
|
//sys kill(pid int, signum int, posix int) (err error)
|
||||||
|
|
||||||
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
||||||
|
|
||||||
func Uname(uname *Utsname) error {
|
func Uname(uname *Utsname) error {
|
||||||
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
||||||
n := unsafe.Sizeof(uname.Sysname)
|
n := unsafe.Sizeof(uname.Sysname)
|
||||||
|
@ -436,6 +423,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
//sysnb Getsid(pid int) (sid int, err error)
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Gettimeofday(tp *Timeval) (err error)
|
||||||
//sysnb Getuid() (uid int)
|
//sysnb Getuid() (uid int)
|
||||||
//sysnb Issetugid() (tainted bool)
|
//sysnb Issetugid() (tainted bool)
|
||||||
//sys Kqueue() (fd int, err error)
|
//sys Kqueue() (fd int, err error)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
|
||||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
@ -21,17 +20,6 @@ func setTimeval(sec, usec int64) Timeval {
|
||||||
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
|
||||||
func Gettimeofday(tv *Timeval) (err error) {
|
|
||||||
// The tv passed to gettimeofday must be non-nil
|
|
||||||
// but is otherwise unused. The answers come back
|
|
||||||
// in the two registers.
|
|
||||||
sec, usec, err := gettimeofday(tv)
|
|
||||||
tv.Sec = int32(sec)
|
|
||||||
tv.Usec = int32(usec)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
k.Ident = uint32(fd)
|
k.Ident = uint32(fd)
|
||||||
k.Filter = int16(mode)
|
k.Filter = int16(mode)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
|
||||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
@ -21,17 +20,6 @@ func setTimeval(sec, usec int64) Timeval {
|
||||||
return Timeval{Sec: sec, Usec: int32(usec)}
|
return Timeval{Sec: sec, Usec: int32(usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
|
||||||
func Gettimeofday(tv *Timeval) (err error) {
|
|
||||||
// The tv passed to gettimeofday must be non-nil
|
|
||||||
// but is otherwise unused. The answers come back
|
|
||||||
// in the two registers.
|
|
||||||
sec, usec, err := gettimeofday(tv)
|
|
||||||
tv.Sec = sec
|
|
||||||
tv.Usec = usec
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
k.Ident = uint64(fd)
|
k.Ident = uint64(fd)
|
||||||
k.Filter = int16(mode)
|
k.Filter = int16(mode)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin,386,!go1.12
|
// +build darwin,arm,!go1.12
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,6 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
||||||
return ENOTSUP
|
return ENOTSUP
|
||||||
}
|
}
|
||||||
|
|
||||||
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
|
|
||||||
return ENOTSUP
|
|
||||||
}
|
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
}
|
}
|
||||||
|
@ -24,17 +20,6 @@ func setTimeval(sec, usec int64) Timeval {
|
||||||
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
|
||||||
func Gettimeofday(tv *Timeval) (err error) {
|
|
||||||
// The tv passed to gettimeofday must be non-nil
|
|
||||||
// but is otherwise unused. The answers come back
|
|
||||||
// in the two registers.
|
|
||||||
sec, usec, err := gettimeofday(tv)
|
|
||||||
tv.Sec = int32(sec)
|
|
||||||
tv.Usec = int32(usec)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
k.Ident = uint32(fd)
|
k.Ident = uint32(fd)
|
||||||
k.Filter = int16(mode)
|
k.Filter = int16(mode)
|
||||||
|
|
|
@ -14,10 +14,6 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
||||||
return ENOTSUP
|
return ENOTSUP
|
||||||
}
|
}
|
||||||
|
|
||||||
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
|
|
||||||
return ENOTSUP
|
|
||||||
}
|
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
return Timespec{Sec: sec, Nsec: nsec}
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
}
|
}
|
||||||
|
@ -26,17 +22,6 @@ func setTimeval(sec, usec int64) Timeval {
|
||||||
return Timeval{Sec: sec, Usec: int32(usec)}
|
return Timeval{Sec: sec, Usec: int32(usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
|
||||||
func Gettimeofday(tv *Timeval) (err error) {
|
|
||||||
// The tv passed to gettimeofday must be non-nil
|
|
||||||
// but is otherwise unused. The answers come back
|
|
||||||
// in the two registers.
|
|
||||||
sec, usec, err := gettimeofday(tv)
|
|
||||||
tv.Sec = sec
|
|
||||||
tv.Usec = usec
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
k.Ident = uint64(fd)
|
k.Ident = uint64(fd)
|
||||||
k.Filter = int16(mode)
|
k.Filter = int16(mode)
|
||||||
|
|
|
@ -168,6 +168,8 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
||||||
|
|
||||||
func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error {
|
func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error {
|
||||||
err := sysctl(mib, old, oldlen, nil, 0)
|
err := sysctl(mib, old, oldlen, nil, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -36,8 +36,6 @@ var (
|
||||||
// INO64_FIRST from /usr/src/lib/libc/sys/compat-ino64.h
|
// INO64_FIRST from /usr/src/lib/libc/sys/compat-ino64.h
|
||||||
const _ino64First = 1200031
|
const _ino64First = 1200031
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
|
||||||
|
|
||||||
func supportsABI(ver uint32) bool {
|
func supportsABI(ver uint32) bool {
|
||||||
osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") })
|
osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") })
|
||||||
return osreldate >= ver
|
return osreldate >= ver
|
||||||
|
@ -203,6 +201,8 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
||||||
|
|
||||||
func Uname(uname *Utsname) error {
|
func Uname(uname *Utsname) error {
|
||||||
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
||||||
n := unsafe.Sizeof(uname.Sysname)
|
n := unsafe.Sizeof(uname.Sysname)
|
||||||
|
@ -462,8 +462,12 @@ func convertFromDirents11(buf []byte, old []byte) int {
|
||||||
dstPos := 0
|
dstPos := 0
|
||||||
srcPos := 0
|
srcPos := 0
|
||||||
for dstPos+fixedSize < len(buf) && srcPos+oldFixedSize < len(old) {
|
for dstPos+fixedSize < len(buf) && srcPos+oldFixedSize < len(old) {
|
||||||
dstDirent := (*Dirent)(unsafe.Pointer(&buf[dstPos]))
|
var dstDirent Dirent
|
||||||
srcDirent := (*dirent_freebsd11)(unsafe.Pointer(&old[srcPos]))
|
var srcDirent dirent_freebsd11
|
||||||
|
|
||||||
|
// If multiple direntries are written, sometimes when we reach the final one,
|
||||||
|
// we may have cap of old less than size of dirent_freebsd11.
|
||||||
|
copy((*[unsafe.Sizeof(srcDirent)]byte)(unsafe.Pointer(&srcDirent))[:], old[srcPos:])
|
||||||
|
|
||||||
reclen := roundup(fixedSize+int(srcDirent.Namlen)+1, 8)
|
reclen := roundup(fixedSize+int(srcDirent.Namlen)+1, 8)
|
||||||
if dstPos+reclen > len(buf) {
|
if dstPos+reclen > len(buf) {
|
||||||
|
@ -479,6 +483,7 @@ func convertFromDirents11(buf []byte, old []byte) int {
|
||||||
dstDirent.Pad1 = 0
|
dstDirent.Pad1 = 0
|
||||||
|
|
||||||
copy(dstDirent.Name[:], srcDirent.Name[:srcDirent.Namlen])
|
copy(dstDirent.Name[:], srcDirent.Name[:srcDirent.Namlen])
|
||||||
|
copy(buf[dstPos:], (*[unsafe.Sizeof(dstDirent)]byte)(unsafe.Pointer(&dstDirent))[:])
|
||||||
padding := buf[dstPos+fixedSize+int(dstDirent.Namlen) : dstPos+reclen]
|
padding := buf[dstPos+fixedSize+int(dstDirent.Namlen) : dstPos+reclen]
|
||||||
for i := range padding {
|
for i := range padding {
|
||||||
padding[i] = 0
|
padding[i] = 0
|
||||||
|
@ -516,20 +521,10 @@ func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) {
|
||||||
return ptrace(PTRACE_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0)
|
return ptrace(PTRACE_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PtraceGetFsBase(pid int, fsbase *int64) (err error) {
|
|
||||||
return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func PtraceGetRegs(pid int, regsout *Reg) (err error) {
|
func PtraceGetRegs(pid int, regsout *Reg) (err error) {
|
||||||
return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0)
|
return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
|
|
||||||
ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint(countin)}
|
|
||||||
err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
|
|
||||||
return int(ioDesc.Len), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func PtraceLwpEvents(pid int, enable int) (err error) {
|
func PtraceLwpEvents(pid int, enable int) (err error) {
|
||||||
return ptrace(PTRACE_LWPEVENTS, pid, 0, enable)
|
return ptrace(PTRACE_LWPEVENTS, pid, 0, enable)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,3 +54,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
}
|
}
|
||||||
|
|
||||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func PtraceGetFsBase(pid int, fsbase *int64) (err error) {
|
||||||
|
return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
|
||||||
|
ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)}
|
||||||
|
err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
|
||||||
|
return int(ioDesc.Len), err
|
||||||
|
}
|
||||||
|
|
|
@ -54,3 +54,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
}
|
}
|
||||||
|
|
||||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func PtraceGetFsBase(pid int, fsbase *int64) (err error) {
|
||||||
|
return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
|
||||||
|
ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)}
|
||||||
|
err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
|
||||||
|
return int(ioDesc.Len), err
|
||||||
|
}
|
||||||
|
|
|
@ -54,3 +54,9 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
}
|
}
|
||||||
|
|
||||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
|
||||||
|
ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)}
|
||||||
|
err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
|
||||||
|
return int(ioDesc.Len), err
|
||||||
|
}
|
||||||
|
|
|
@ -54,3 +54,9 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
}
|
}
|
||||||
|
|
||||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
|
||||||
|
ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)}
|
||||||
|
err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
|
||||||
|
return int(ioDesc.Len), err
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// illumos system calls not present on Solaris.
|
||||||
|
|
||||||
|
// +build amd64,illumos
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
func bytes2iovec(bs [][]byte) []Iovec {
|
||||||
|
iovecs := make([]Iovec, len(bs))
|
||||||
|
for i, b := range bs {
|
||||||
|
iovecs[i].SetLen(len(b))
|
||||||
|
if len(b) > 0 {
|
||||||
|
// somehow Iovec.Base on illumos is (*int8), not (*byte)
|
||||||
|
iovecs[i].Base = (*int8)(unsafe.Pointer(&b[0]))
|
||||||
|
} else {
|
||||||
|
iovecs[i].Base = (*int8)(unsafe.Pointer(&_zero))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iovecs
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys readv(fd int, iovs []Iovec) (n int, err error)
|
||||||
|
|
||||||
|
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
n, err = readv(fd, iovecs)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error)
|
||||||
|
|
||||||
|
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
n, err = preadv(fd, iovecs, off)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys writev(fd int, iovs []Iovec) (n int, err error)
|
||||||
|
|
||||||
|
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
n, err = writev(fd, iovecs)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
|
||||||
|
|
||||||
|
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
n, err = pwritev(fd, iovecs, off)
|
||||||
|
return n, err
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue