mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
vendor: Add dependencies for strelaypoolsrv
This commit is contained in:
parent
7d434aa9c4
commit
59370588dd
15
vendor/github.com/oschwald/geoip2-golang/LICENSE
generated
vendored
Normal file
15
vendor/github.com/oschwald/geoip2-golang/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2015, Gregory J. Oschwald <oschwald@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
288
vendor/github.com/oschwald/geoip2-golang/reader.go
generated
vendored
Normal file
288
vendor/github.com/oschwald/geoip2-golang/reader.go
generated
vendored
Normal file
@ -0,0 +1,288 @@
|
||||
// Package geoip2 provides a wrapper around the maxminddb package for
|
||||
// easy use with the MaxMind GeoIP2 and GeoLite2 databases. The records for
|
||||
// the IP address is returned from this package as well-formed structures
|
||||
// that match the internal layout of data from MaxMind.
|
||||
package geoip2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/oschwald/maxminddb-golang"
|
||||
)
|
||||
|
||||
// The City structure corresponds to the data in the GeoIP2/GeoLite2 City
|
||||
// databases.
|
||||
type City struct {
|
||||
City struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"city"`
|
||||
Continent struct {
|
||||
Code string `maxminddb:"code"`
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"continent"`
|
||||
Country struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"country"`
|
||||
Location struct {
|
||||
AccuracyRadius uint16 `maxminddb:"accuracy_radius"`
|
||||
Latitude float64 `maxminddb:"latitude"`
|
||||
Longitude float64 `maxminddb:"longitude"`
|
||||
MetroCode uint `maxminddb:"metro_code"`
|
||||
TimeZone string `maxminddb:"time_zone"`
|
||||
} `maxminddb:"location"`
|
||||
Postal struct {
|
||||
Code string `maxminddb:"code"`
|
||||
} `maxminddb:"postal"`
|
||||
RegisteredCountry struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"registered_country"`
|
||||
RepresentedCountry struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
Type string `maxminddb:"type"`
|
||||
} `maxminddb:"represented_country"`
|
||||
Subdivisions []struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"subdivisions"`
|
||||
Traits struct {
|
||||
IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
|
||||
IsSatelliteProvider bool `maxminddb:"is_satellite_provider"`
|
||||
} `maxminddb:"traits"`
|
||||
}
|
||||
|
||||
// The Country structure corresponds to the data in the GeoIP2/GeoLite2
|
||||
// Country databases.
|
||||
type Country struct {
|
||||
Continent struct {
|
||||
Code string `maxminddb:"code"`
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"continent"`
|
||||
Country struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"country"`
|
||||
RegisteredCountry struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
} `maxminddb:"registered_country"`
|
||||
RepresentedCountry struct {
|
||||
GeoNameID uint `maxminddb:"geoname_id"`
|
||||
IsoCode string `maxminddb:"iso_code"`
|
||||
Names map[string]string `maxminddb:"names"`
|
||||
Type string `maxminddb:"type"`
|
||||
} `maxminddb:"represented_country"`
|
||||
Traits struct {
|
||||
IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
|
||||
IsSatelliteProvider bool `maxminddb:"is_satellite_provider"`
|
||||
} `maxminddb:"traits"`
|
||||
}
|
||||
|
||||
// The AnonymousIP structure corresponds to the data in the GeoIP2
|
||||
// Anonymous IP database.
|
||||
type AnonymousIP struct {
|
||||
IsAnonymous bool `maxminddb:"is_anonymous"`
|
||||
IsAnonymousVPN bool `maxminddb:"is_anonymous_vpn"`
|
||||
IsHostingProvider bool `maxminddb:"is_hosting_provider"`
|
||||
IsPublicProxy bool `maxminddb:"is_public_proxy"`
|
||||
IsTorExitNode bool `maxminddb:"is_tor_exit_node"`
|
||||
}
|
||||
|
||||
// The ConnectionType structure corresponds to the data in the GeoIP2
|
||||
// Connection-Type database.
|
||||
type ConnectionType struct {
|
||||
ConnectionType string `maxminddb:"connection_type"`
|
||||
}
|
||||
|
||||
// The Domain structure corresponds to the data in the GeoIP2 Domain database.
|
||||
type Domain struct {
|
||||
Domain string `maxminddb:"domain"`
|
||||
}
|
||||
|
||||
// The ISP structure corresponds to the data in the GeoIP2 ISP database.
|
||||
type ISP struct {
|
||||
AutonomousSystemNumber uint `maxminddb:"autonomous_system_number"`
|
||||
AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
|
||||
ISP string `maxminddb:"isp"`
|
||||
Organization string `maxminddb:"organization"`
|
||||
}
|
||||
|
||||
type databaseType int
|
||||
|
||||
const (
|
||||
isAnonymousIP = 1 << iota
|
||||
isCity
|
||||
isConnectionType
|
||||
isCountry
|
||||
isDomain
|
||||
isEnterprise
|
||||
isISP
|
||||
)
|
||||
|
||||
// Reader holds the maxminddb.Reader structure. It should be created
|
||||
// using the Open function.
|
||||
type Reader struct {
|
||||
mmdbReader *maxminddb.Reader
|
||||
databaseType databaseType
|
||||
}
|
||||
|
||||
// InvalidMethodError is returned when a lookup method is called on a
|
||||
// database that it does not support. For instance, calling the ISP method
|
||||
// on a City database.
|
||||
type InvalidMethodError struct {
|
||||
Method string
|
||||
DatabaseType string
|
||||
}
|
||||
|
||||
func (e InvalidMethodError) Error() string {
|
||||
return fmt.Sprintf(`geoip2: the %s method does not support the %s database`,
|
||||
e.Method, e.DatabaseType)
|
||||
}
|
||||
|
||||
// UnknownDatabaseTypeError is returned when an unknown database type is
|
||||
// opened.
|
||||
type UnknownDatabaseTypeError struct {
|
||||
DatabaseType string
|
||||
}
|
||||
|
||||
func (e UnknownDatabaseTypeError) Error() string {
|
||||
return fmt.Sprintf(`geoip2: reader does not support the "%s" database type`,
|
||||
e.DatabaseType)
|
||||
}
|
||||
|
||||
// Open takes a string path to a file and returns a Reader structure or an
|
||||
// error. The database file is opened using a memory map. Use the Close method
|
||||
// on the Reader object to return the resources to the system.
|
||||
func Open(file string) (*Reader, error) {
|
||||
reader, err := maxminddb.Open(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbType, err := getDBType(reader)
|
||||
return &Reader{reader, dbType}, err
|
||||
}
|
||||
|
||||
// FromBytes takes a byte slice corresponding to a GeoIP2/GeoLite2 database
|
||||
// file and returns a Reader structure or an error.
|
||||
func FromBytes(bytes []byte) (*Reader, error) {
|
||||
reader, err := maxminddb.FromBytes(bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbType, err := getDBType(reader)
|
||||
return &Reader{reader, dbType}, err
|
||||
}
|
||||
|
||||
func getDBType(reader *maxminddb.Reader) (databaseType, error) {
|
||||
switch reader.Metadata.DatabaseType {
|
||||
case "GeoIP2-Anonymous-IP":
|
||||
return isAnonymousIP, nil
|
||||
// We allow City lookups on Country for back compat
|
||||
case "GeoLite2-City", "GeoIP2-City", "GeoIP2-Precision-City", "GeoLite2-Country",
|
||||
"GeoIP2-Country":
|
||||
return isCity | isCountry, nil
|
||||
case "GeoIP2-Connection-Type":
|
||||
return isConnectionType, nil
|
||||
case "GeoIP2-Domain":
|
||||
return isDomain, nil
|
||||
case "GeoIP2-Enterprise":
|
||||
return isEnterprise | isCity | isCountry, nil
|
||||
case "GeoIP2-ISP", "GeoIP2-Precision-ISP":
|
||||
return isISP, nil
|
||||
default:
|
||||
return 0, UnknownDatabaseTypeError{reader.Metadata.DatabaseType}
|
||||
}
|
||||
}
|
||||
|
||||
// City takes an IP address as a net.IP struct and returns a City struct
|
||||
// and/or an error. Although this can be used with other databases, this
|
||||
// method generally should be used with the GeoIP2 or GeoLite2 City databases.
|
||||
func (r *Reader) City(ipAddress net.IP) (*City, error) {
|
||||
if isCity&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"City", r.Metadata().DatabaseType}
|
||||
}
|
||||
var city City
|
||||
err := r.mmdbReader.Lookup(ipAddress, &city)
|
||||
return &city, err
|
||||
}
|
||||
|
||||
// Country takes an IP address as a net.IP struct and returns a Country struct
|
||||
// and/or an error. Although this can be used with other databases, this
|
||||
// method generally should be used with the GeoIP2 or GeoLite2 Country
|
||||
// databases.
|
||||
func (r *Reader) Country(ipAddress net.IP) (*Country, error) {
|
||||
if isCountry&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"Country", r.Metadata().DatabaseType}
|
||||
}
|
||||
var country Country
|
||||
err := r.mmdbReader.Lookup(ipAddress, &country)
|
||||
return &country, err
|
||||
}
|
||||
|
||||
// AnonymousIP takes an IP address as a net.IP struct and returns a
|
||||
// AnonymousIP struct and/or an error.
|
||||
func (r *Reader) AnonymousIP(ipAddress net.IP) (*AnonymousIP, error) {
|
||||
if isAnonymousIP&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"AnonymousIP", r.Metadata().DatabaseType}
|
||||
}
|
||||
var anonIP AnonymousIP
|
||||
err := r.mmdbReader.Lookup(ipAddress, &anonIP)
|
||||
return &anonIP, err
|
||||
}
|
||||
|
||||
// ConnectionType takes an IP address as a net.IP struct and returns a
|
||||
// ConnectionType struct and/or an error
|
||||
func (r *Reader) ConnectionType(ipAddress net.IP) (*ConnectionType, error) {
|
||||
if isConnectionType&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"ConnectionType", r.Metadata().DatabaseType}
|
||||
}
|
||||
var val ConnectionType
|
||||
err := r.mmdbReader.Lookup(ipAddress, &val)
|
||||
return &val, err
|
||||
}
|
||||
|
||||
// Domain takes an IP address as a net.IP struct and returns a
|
||||
// Domain struct and/or an error
|
||||
func (r *Reader) Domain(ipAddress net.IP) (*Domain, error) {
|
||||
if isDomain&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"Domain", r.Metadata().DatabaseType}
|
||||
}
|
||||
var val Domain
|
||||
err := r.mmdbReader.Lookup(ipAddress, &val)
|
||||
return &val, err
|
||||
}
|
||||
|
||||
// ISP takes an IP address as a net.IP struct and returns a ISP struct and/or
|
||||
// an error
|
||||
func (r *Reader) ISP(ipAddress net.IP) (*ISP, error) {
|
||||
if isISP&r.databaseType == 0 {
|
||||
return nil, InvalidMethodError{"ISP", r.Metadata().DatabaseType}
|
||||
}
|
||||
var val ISP
|
||||
err := r.mmdbReader.Lookup(ipAddress, &val)
|
||||
return &val, err
|
||||
}
|
||||
|
||||
// Metadata takes no arguments and returns a struct containing metadata about
|
||||
// the MaxMind database in use by the Reader.
|
||||
func (r *Reader) Metadata() maxminddb.Metadata {
|
||||
return r.mmdbReader.Metadata
|
||||
}
|
||||
|
||||
// Close unmaps the database file from virtual memory and returns the
|
||||
// resources to the system.
|
||||
func (r *Reader) Close() error {
|
||||
return r.mmdbReader.Close()
|
||||
}
|
13
vendor/github.com/oschwald/maxminddb-golang/LICENSE
generated
vendored
Normal file
13
vendor/github.com/oschwald/maxminddb-golang/LICENSE
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright (c) 2015, Gregory J. Oschwald <oschwald@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
559
vendor/github.com/oschwald/maxminddb-golang/decoder.go
generated
vendored
Normal file
559
vendor/github.com/oschwald/maxminddb-golang/decoder.go
generated
vendored
Normal file
@ -0,0 +1,559 @@
|
||||
package maxminddb
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type decoder struct {
|
||||
buffer []byte
|
||||
}
|
||||
|
||||
type dataType int
|
||||
|
||||
const (
|
||||
_Extended dataType = iota
|
||||
_Pointer
|
||||
_String
|
||||
_Float64
|
||||
_Bytes
|
||||
_Uint16
|
||||
_Uint32
|
||||
_Map
|
||||
_Int32
|
||||
_Uint64
|
||||
_Uint128
|
||||
_Slice
|
||||
_Container
|
||||
_Marker
|
||||
_Bool
|
||||
_Float32
|
||||
)
|
||||
|
||||
func (d *decoder) decode(offset uint, result reflect.Value) (uint, error) {
|
||||
typeNum, size, newOffset := d.decodeCtrlData(offset)
|
||||
|
||||
if typeNum != _Pointer && result.Kind() == reflect.Uintptr {
|
||||
result.Set(reflect.ValueOf(uintptr(offset)))
|
||||
return d.nextValueOffset(offset, 1), nil
|
||||
}
|
||||
return d.decodeFromType(typeNum, size, newOffset, result)
|
||||
}
|
||||
|
||||
func (d *decoder) decodeCtrlData(offset uint) (dataType, uint, uint) {
|
||||
newOffset := offset + 1
|
||||
ctrlByte := d.buffer[offset]
|
||||
|
||||
typeNum := dataType(ctrlByte >> 5)
|
||||
if typeNum == _Extended {
|
||||
typeNum = dataType(d.buffer[newOffset] + 7)
|
||||
newOffset++
|
||||
}
|
||||
|
||||
var size uint
|
||||
size, newOffset = d.sizeFromCtrlByte(ctrlByte, newOffset, typeNum)
|
||||
return typeNum, size, newOffset
|
||||
}
|
||||
|
||||
func (d *decoder) sizeFromCtrlByte(ctrlByte byte, offset uint, typeNum dataType) (uint, uint) {
|
||||
size := uint(ctrlByte & 0x1f)
|
||||
if typeNum == _Extended {
|
||||
return size, offset
|
||||
}
|
||||
|
||||
var bytesToRead uint
|
||||
if size > 28 {
|
||||
bytesToRead = size - 28
|
||||
}
|
||||
|
||||
newOffset := offset + bytesToRead
|
||||
sizeBytes := d.buffer[offset:newOffset]
|
||||
|
||||
switch {
|
||||
case size == 29:
|
||||
size = 29 + uint(sizeBytes[0])
|
||||
case size == 30:
|
||||
size = 285 + uint(uintFromBytes(0, sizeBytes))
|
||||
case size > 30:
|
||||
size = uint(uintFromBytes(0, sizeBytes)) + 65821
|
||||
}
|
||||
return size, newOffset
|
||||
}
|
||||
|
||||
func (d *decoder) decodeFromType(dtype dataType, size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
for result.Kind() == reflect.Ptr {
|
||||
if result.IsNil() {
|
||||
result.Set(reflect.New(result.Type().Elem()))
|
||||
}
|
||||
result = result.Elem()
|
||||
}
|
||||
|
||||
switch dtype {
|
||||
case _Bool:
|
||||
return d.unmarshalBool(size, offset, result)
|
||||
case _Bytes:
|
||||
return d.unmarshalBytes(size, offset, result)
|
||||
case _Float32:
|
||||
return d.unmarshalFloat32(size, offset, result)
|
||||
case _Float64:
|
||||
return d.unmarshalFloat64(size, offset, result)
|
||||
case _Int32:
|
||||
return d.unmarshalInt32(size, offset, result)
|
||||
case _Map:
|
||||
return d.unmarshalMap(size, offset, result)
|
||||
case _Pointer:
|
||||
return d.unmarshalPointer(size, offset, result)
|
||||
case _Slice:
|
||||
return d.unmarshalSlice(size, offset, result)
|
||||
case _String:
|
||||
return d.unmarshalString(size, offset, result)
|
||||
case _Uint16:
|
||||
return d.unmarshalUint(size, offset, result, 16)
|
||||
case _Uint32:
|
||||
return d.unmarshalUint(size, offset, result, 32)
|
||||
case _Uint64:
|
||||
return d.unmarshalUint(size, offset, result, 64)
|
||||
case _Uint128:
|
||||
return d.unmarshalUint128(size, offset, result)
|
||||
default:
|
||||
return 0, newInvalidDatabaseError("unknown type: %d", dtype)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalBool(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
if size > 1 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (bool size of %v)", size)
|
||||
}
|
||||
value, newOffset, err := d.decodeBool(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Bool:
|
||||
result.SetBool(value)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalBytes(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
value, newOffset, err := d.decodeBytes(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Slice:
|
||||
result.SetBytes(value)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalFloat32(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
if size != 4 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (float32 size of %v)", size)
|
||||
}
|
||||
value, newOffset, err := d.decodeFloat32(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Float32, reflect.Float64:
|
||||
result.SetFloat(float64(value))
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalFloat64(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
|
||||
if size != 8 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (float 64 size of %v)", size)
|
||||
}
|
||||
value, newOffset, err := d.decodeFloat64(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Float32, reflect.Float64:
|
||||
if result.OverflowFloat(value) {
|
||||
return 0, newUnmarshalTypeError(value, result.Type())
|
||||
}
|
||||
result.SetFloat(value)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalInt32(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
if size > 4 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (int32 size of %v)", size)
|
||||
}
|
||||
value, newOffset, err := d.decodeInt(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
n := int64(value)
|
||||
if result.OverflowInt(n) {
|
||||
return 0, newUnmarshalTypeError(value, result.Type())
|
||||
}
|
||||
result.SetInt(n)
|
||||
return newOffset, nil
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
n := uint64(value)
|
||||
if result.OverflowUint(n) {
|
||||
return 0, newUnmarshalTypeError(value, result.Type())
|
||||
}
|
||||
result.SetUint(n)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalMap(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return 0, newUnmarshalTypeError("map", result.Type())
|
||||
case reflect.Struct:
|
||||
return d.decodeStruct(size, offset, result)
|
||||
case reflect.Map:
|
||||
return d.decodeMap(size, offset, result)
|
||||
case reflect.Interface:
|
||||
rv := reflect.ValueOf(make(map[string]interface{}, size))
|
||||
newOffset, err := d.decodeMap(size, offset, rv)
|
||||
result.Set(rv)
|
||||
return newOffset, err
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalPointer(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
pointer, newOffset := d.decodePointer(size, offset)
|
||||
_, err := d.decode(pointer, result)
|
||||
return newOffset, err
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalSlice(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return 0, newUnmarshalTypeError("array", result.Type())
|
||||
case reflect.Slice:
|
||||
return d.decodeSlice(size, offset, result)
|
||||
case reflect.Interface:
|
||||
a := []interface{}{}
|
||||
rv := reflect.ValueOf(&a).Elem()
|
||||
newOffset, err := d.decodeSlice(size, offset, rv)
|
||||
result.Set(rv)
|
||||
return newOffset, err
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalString(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
value, newOffset, err := d.decodeString(size, offset)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.String:
|
||||
result.SetString(value)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalUint(size uint, offset uint, result reflect.Value, uintType uint) (uint, error) {
|
||||
if size > uintType/8 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (uint%v size of %v)", uintType, size)
|
||||
}
|
||||
|
||||
value, newOffset, err := d.decodeUint(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
n := int64(value)
|
||||
if result.OverflowInt(n) {
|
||||
return 0, newUnmarshalTypeError(value, result.Type())
|
||||
}
|
||||
result.SetInt(n)
|
||||
return newOffset, nil
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
if result.OverflowUint(value) {
|
||||
return 0, newUnmarshalTypeError(value, result.Type())
|
||||
}
|
||||
result.SetUint(value)
|
||||
return newOffset, nil
|
||||
case reflect.Interface:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshalUint128(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
if size > 16 {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's data section contains bad data (uint128 size of %v)", size)
|
||||
}
|
||||
value, newOffset, err := d.decodeUint128(size, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// XXX - this should allow *big.Int rather than just bigInt
|
||||
// Currently this is reported as invalid
|
||||
switch result.Kind() {
|
||||
default:
|
||||
return newOffset, newUnmarshalTypeError(value, result.Type())
|
||||
case reflect.Struct:
|
||||
result.Set(reflect.ValueOf(*value))
|
||||
return newOffset, nil
|
||||
case reflect.Interface, reflect.Ptr:
|
||||
result.Set(reflect.ValueOf(value))
|
||||
return newOffset, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) decodeBool(size uint, offset uint) (bool, uint, error) {
|
||||
return size != 0, offset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeBytes(size uint, offset uint) ([]byte, uint, error) {
|
||||
newOffset := offset + size
|
||||
bytes := make([]byte, size)
|
||||
copy(bytes, d.buffer[offset:newOffset])
|
||||
return bytes, newOffset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeFloat64(size uint, offset uint) (float64, uint, error) {
|
||||
newOffset := offset + size
|
||||
bits := binary.BigEndian.Uint64(d.buffer[offset:newOffset])
|
||||
return math.Float64frombits(bits), newOffset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeFloat32(size uint, offset uint) (float32, uint, error) {
|
||||
newOffset := offset + size
|
||||
bits := binary.BigEndian.Uint32(d.buffer[offset:newOffset])
|
||||
return math.Float32frombits(bits), newOffset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeInt(size uint, offset uint) (int, uint, error) {
|
||||
newOffset := offset + size
|
||||
var val int32
|
||||
for _, b := range d.buffer[offset:newOffset] {
|
||||
val = (val << 8) | int32(b)
|
||||
}
|
||||
return int(val), newOffset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeMap(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
if result.IsNil() {
|
||||
result.Set(reflect.MakeMap(result.Type()))
|
||||
}
|
||||
|
||||
for i := uint(0); i < size; i++ {
|
||||
var key string
|
||||
var err error
|
||||
key, offset, err = d.decodeKeyString(offset)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
value := reflect.New(result.Type().Elem())
|
||||
offset, err = d.decode(offset, value)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
result.SetMapIndex(reflect.ValueOf(key), value.Elem())
|
||||
}
|
||||
return offset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodePointer(size uint, offset uint) (uint, uint) {
|
||||
pointerSize := ((size >> 3) & 0x3) + 1
|
||||
newOffset := offset + pointerSize
|
||||
pointerBytes := d.buffer[offset:newOffset]
|
||||
var prefix uint64
|
||||
if pointerSize == 4 {
|
||||
prefix = 0
|
||||
} else {
|
||||
prefix = uint64(size & 0x7)
|
||||
}
|
||||
unpacked := uint(uintFromBytes(prefix, pointerBytes))
|
||||
|
||||
var pointerValueOffset uint
|
||||
switch pointerSize {
|
||||
case 1:
|
||||
pointerValueOffset = 0
|
||||
case 2:
|
||||
pointerValueOffset = 2048
|
||||
case 3:
|
||||
pointerValueOffset = 526336
|
||||
case 4:
|
||||
pointerValueOffset = 0
|
||||
}
|
||||
|
||||
pointer := unpacked + pointerValueOffset
|
||||
|
||||
return pointer, newOffset
|
||||
}
|
||||
|
||||
func (d *decoder) decodeSlice(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
result.Set(reflect.MakeSlice(result.Type(), int(size), int(size)))
|
||||
for i := 0; i < int(size); i++ {
|
||||
var err error
|
||||
offset, err = d.decode(offset, result.Index(i))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeString(size uint, offset uint) (string, uint, error) {
|
||||
newOffset := offset + size
|
||||
return string(d.buffer[offset:newOffset]), newOffset, nil
|
||||
}
|
||||
|
||||
var (
|
||||
fieldMap = map[reflect.Type]map[string]int{}
|
||||
fieldMapMu sync.RWMutex
|
||||
)
|
||||
|
||||
func (d *decoder) decodeStruct(size uint, offset uint, result reflect.Value) (uint, error) {
|
||||
resultType := result.Type()
|
||||
|
||||
fieldMapMu.RLock()
|
||||
fields, ok := fieldMap[resultType]
|
||||
fieldMapMu.RUnlock()
|
||||
if !ok {
|
||||
numFields := resultType.NumField()
|
||||
fields = make(map[string]int, numFields)
|
||||
for i := 0; i < numFields; i++ {
|
||||
fieldType := resultType.Field(i)
|
||||
|
||||
fieldName := fieldType.Name
|
||||
if tag := fieldType.Tag.Get("maxminddb"); tag != "" {
|
||||
fieldName = tag
|
||||
}
|
||||
fields[fieldName] = i
|
||||
}
|
||||
fieldMapMu.Lock()
|
||||
fieldMap[resultType] = fields
|
||||
fieldMapMu.Unlock()
|
||||
}
|
||||
|
||||
for i := uint(0); i < size; i++ {
|
||||
var (
|
||||
err error
|
||||
key string
|
||||
)
|
||||
key, offset, err = d.decodeStructKey(offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i, ok := fields[key]
|
||||
if !ok {
|
||||
offset = d.nextValueOffset(offset, 1)
|
||||
continue
|
||||
}
|
||||
offset, err = d.decode(offset, result.Field(i))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeUint(size uint, offset uint) (uint64, uint, error) {
|
||||
newOffset := offset + size
|
||||
val := uintFromBytes(0, d.buffer[offset:newOffset])
|
||||
|
||||
return val, newOffset, nil
|
||||
}
|
||||
|
||||
func (d *decoder) decodeUint128(size uint, offset uint) (*big.Int, uint, error) {
|
||||
newOffset := offset + size
|
||||
val := new(big.Int)
|
||||
val.SetBytes(d.buffer[offset:newOffset])
|
||||
|
||||
return val, newOffset, nil
|
||||
}
|
||||
|
||||
func uintFromBytes(prefix uint64, uintBytes []byte) uint64 {
|
||||
val := prefix
|
||||
for _, b := range uintBytes {
|
||||
val = (val << 8) | uint64(b)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func (d *decoder) decodeKeyString(offset uint) (string, uint, error) {
|
||||
typeNum, size, newOffset := d.decodeCtrlData(offset)
|
||||
if typeNum == _Pointer {
|
||||
pointer, ptrOffset := d.decodePointer(size, newOffset)
|
||||
key, _, err := d.decodeKeyString(pointer)
|
||||
return key, ptrOffset, err
|
||||
}
|
||||
if typeNum != _String {
|
||||
return "", 0, newInvalidDatabaseError("unexpected type when decoding string: %v", typeNum)
|
||||
}
|
||||
return d.decodeString(size, newOffset)
|
||||
}
|
||||
|
||||
// This function is used to skip ahead to the next value without decoding
|
||||
// the one at the offset passed in. The size bits have different meanings for
|
||||
// different data types
|
||||
func (d *decoder) nextValueOffset(offset uint, numberToSkip uint) uint {
|
||||
if numberToSkip == 0 {
|
||||
return offset
|
||||
}
|
||||
typeNum, size, offset := d.decodeCtrlData(offset)
|
||||
switch typeNum {
|
||||
case _Pointer:
|
||||
_, offset = d.decodePointer(size, offset)
|
||||
case _Map:
|
||||
numberToSkip += 2 * size
|
||||
case _Slice:
|
||||
numberToSkip += size
|
||||
case _Bool:
|
||||
default:
|
||||
offset += size
|
||||
}
|
||||
return d.nextValueOffset(offset, numberToSkip-1)
|
||||
}
|
38
vendor/github.com/oschwald/maxminddb-golang/errors.go
generated
vendored
Normal file
38
vendor/github.com/oschwald/maxminddb-golang/errors.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
package maxminddb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// InvalidDatabaseError is returned when the database contains invalid data
|
||||
// and cannot be parsed.
|
||||
type InvalidDatabaseError struct {
|
||||
message string
|
||||
}
|
||||
|
||||
func newInvalidDatabaseError(format string, args ...interface{}) InvalidDatabaseError {
|
||||
return InvalidDatabaseError{fmt.Sprintf(format, args...)}
|
||||
}
|
||||
|
||||
func (e InvalidDatabaseError) Error() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
// UnmarshalTypeError is returned when the value in the database cannot be
|
||||
// assigned to the specified data type.
|
||||
type UnmarshalTypeError struct {
|
||||
Value string // stringified copy of the database value that caused the error
|
||||
Type reflect.Type // type of the value that could not be assign to
|
||||
}
|
||||
|
||||
func newUnmarshalTypeError(value interface{}, rType reflect.Type) UnmarshalTypeError {
|
||||
return UnmarshalTypeError{
|
||||
Value: fmt.Sprintf("%v", value),
|
||||
Type: rType,
|
||||
}
|
||||
}
|
||||
|
||||
func (e UnmarshalTypeError) Error() string {
|
||||
return fmt.Sprintf("maxminddb: cannot unmarshal %s into type %s", e.Value, e.Type.String())
|
||||
}
|
7
vendor/github.com/oschwald/maxminddb-golang/key_appengine.go
generated
vendored
Normal file
7
vendor/github.com/oschwald/maxminddb-golang/key_appengine.go
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// +build appengine
|
||||
|
||||
package maxminddb
|
||||
|
||||
func (d *decoder) decodeStructKey(offset uint) (string, uint, error) {
|
||||
return d.decodeKeyString(offset)
|
||||
}
|
28
vendor/github.com/oschwald/maxminddb-golang/key_other.go
generated
vendored
Normal file
28
vendor/github.com/oschwald/maxminddb-golang/key_other.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// +build !appengine
|
||||
|
||||
package maxminddb
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// decodeStructKey returns a string which points into the database. Don't keep
|
||||
// it around.
|
||||
func (d *decoder) decodeStructKey(offset uint) (string, uint, error) {
|
||||
typeNum, size, newOffset := d.decodeCtrlData(offset)
|
||||
switch typeNum {
|
||||
case _Pointer:
|
||||
pointer, ptrOffset := d.decodePointer(size, newOffset)
|
||||
s, _, err := d.decodeStructKey(pointer)
|
||||
return s, ptrOffset, err
|
||||
case _String:
|
||||
var s string
|
||||
val := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
||||
val.Data = uintptr(unsafe.Pointer(&d.buffer[newOffset]))
|
||||
val.Len = int(size)
|
||||
return s, newOffset + size, nil
|
||||
default:
|
||||
return "", 0, newInvalidDatabaseError("unexpected type when decoding struct key: %v", typeNum)
|
||||
}
|
||||
}
|
17
vendor/github.com/oschwald/maxminddb-golang/mmap_unix.go
generated
vendored
Normal file
17
vendor/github.com/oschwald/maxminddb-golang/mmap_unix.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// +build !windows,!appengine
|
||||
|
||||
package maxminddb
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func mmap(fd int, length int) (data []byte, err error) {
|
||||
return unix.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
|
||||
}
|
||||
|
||||
func munmap(b []byte) (err error) {
|
||||
return unix.Munmap(b)
|
||||
}
|
83
vendor/github.com/oschwald/maxminddb-golang/mmap_windows.go
generated
vendored
Normal file
83
vendor/github.com/oschwald/maxminddb-golang/mmap_windows.go
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
package maxminddb
|
||||
|
||||
// Windows support largely borrowed from mmap-go.
|
||||
//
|
||||
// Copyright 2011 Evan Shaw. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"reflect"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
type memoryMap []byte
|
||||
|
||||
// Windows
|
||||
var handleLock sync.Mutex
|
||||
var handleMap = map[uintptr]windows.Handle{}
|
||||
|
||||
func mmap(fd int, length int) (data []byte, err error) {
|
||||
h, errno := windows.CreateFileMapping(windows.Handle(fd), nil,
|
||||
uint32(windows.PAGE_READONLY), 0, uint32(length), nil)
|
||||
if h == 0 {
|
||||
return nil, os.NewSyscallError("CreateFileMapping", errno)
|
||||
}
|
||||
|
||||
addr, errno := windows.MapViewOfFile(h, uint32(windows.FILE_MAP_READ), 0,
|
||||
0, uintptr(length))
|
||||
if addr == 0 {
|
||||
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
||||
}
|
||||
handleLock.Lock()
|
||||
handleMap[addr] = h
|
||||
handleLock.Unlock()
|
||||
|
||||
m := memoryMap{}
|
||||
dh := m.header()
|
||||
dh.Data = addr
|
||||
dh.Len = length
|
||||
dh.Cap = dh.Len
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m *memoryMap) header() *reflect.SliceHeader {
|
||||
return (*reflect.SliceHeader)(unsafe.Pointer(m))
|
||||
}
|
||||
|
||||
func flush(addr, len uintptr) error {
|
||||
errno := windows.FlushViewOfFile(addr, len)
|
||||
return os.NewSyscallError("FlushViewOfFile", errno)
|
||||
}
|
||||
|
||||
func munmap(b []byte) (err error) {
|
||||
m := memoryMap(b)
|
||||
dh := m.header()
|
||||
|
||||
addr := dh.Data
|
||||
length := uintptr(dh.Len)
|
||||
|
||||
flush(addr, length)
|
||||
err = windows.UnmapViewOfFile(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
handleLock.Lock()
|
||||
defer handleLock.Unlock()
|
||||
handle, ok := handleMap[addr]
|
||||
if !ok {
|
||||
// should be impossible; we would've errored above
|
||||
return errors.New("unknown base address")
|
||||
}
|
||||
delete(handleMap, addr)
|
||||
|
||||
e := windows.CloseHandle(windows.Handle(handle))
|
||||
return os.NewSyscallError("CloseHandle", e)
|
||||
}
|
246
vendor/github.com/oschwald/maxminddb-golang/reader.go
generated
vendored
Normal file
246
vendor/github.com/oschwald/maxminddb-golang/reader.go
generated
vendored
Normal file
@ -0,0 +1,246 @@
|
||||
package maxminddb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// NotFound is returned by LookupOffset when a matched root record offset
|
||||
// cannot be found.
|
||||
NotFound = ^uintptr(0)
|
||||
|
||||
dataSectionSeparatorSize = 16
|
||||
)
|
||||
|
||||
var metadataStartMarker = []byte("\xAB\xCD\xEFMaxMind.com")
|
||||
|
||||
// Reader holds the data corresponding to the MaxMind DB file. Its only public
|
||||
// field is Metadata, which contains the metadata from the MaxMind DB file.
|
||||
type Reader struct {
|
||||
hasMappedFile bool
|
||||
buffer []byte
|
||||
decoder decoder
|
||||
Metadata Metadata
|
||||
ipv4Start uint
|
||||
}
|
||||
|
||||
// Metadata holds the metadata decoded from the MaxMind DB file. In particular
|
||||
// in has the format version, the build time as Unix epoch time, the database
|
||||
// type and description, the IP version supported, and a slice of the natural
|
||||
// languages included.
|
||||
type Metadata struct {
|
||||
BinaryFormatMajorVersion uint `maxminddb:"binary_format_major_version"`
|
||||
BinaryFormatMinorVersion uint `maxminddb:"binary_format_minor_version"`
|
||||
BuildEpoch uint `maxminddb:"build_epoch"`
|
||||
DatabaseType string `maxminddb:"database_type"`
|
||||
Description map[string]string `maxminddb:"description"`
|
||||
IPVersion uint `maxminddb:"ip_version"`
|
||||
Languages []string `maxminddb:"languages"`
|
||||
NodeCount uint `maxminddb:"node_count"`
|
||||
RecordSize uint `maxminddb:"record_size"`
|
||||
}
|
||||
|
||||
// FromBytes takes a byte slice corresponding to a MaxMind DB file and returns
|
||||
// a Reader structure or an error.
|
||||
func FromBytes(buffer []byte) (*Reader, error) {
|
||||
metadataStart := bytes.LastIndex(buffer, metadataStartMarker)
|
||||
|
||||
if metadataStart == -1 {
|
||||
return nil, newInvalidDatabaseError("error opening database: invalid MaxMind DB file")
|
||||
}
|
||||
|
||||
metadataStart += len(metadataStartMarker)
|
||||
metadataDecoder := decoder{buffer[metadataStart:]}
|
||||
|
||||
var metadata Metadata
|
||||
|
||||
rvMetdata := reflect.ValueOf(&metadata)
|
||||
_, err := metadataDecoder.decode(0, rvMetdata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
searchTreeSize := metadata.NodeCount * metadata.RecordSize / 4
|
||||
dataSectionStart := searchTreeSize + dataSectionSeparatorSize
|
||||
dataSectionEnd := uint(metadataStart - len(metadataStartMarker))
|
||||
if dataSectionStart > dataSectionEnd {
|
||||
return nil, newInvalidDatabaseError("the MaxMind DB contains invalid metadata")
|
||||
}
|
||||
d := decoder{
|
||||
buffer[searchTreeSize+dataSectionSeparatorSize : metadataStart-len(metadataStartMarker)],
|
||||
}
|
||||
|
||||
reader := &Reader{
|
||||
buffer: buffer,
|
||||
decoder: d,
|
||||
Metadata: metadata,
|
||||
ipv4Start: 0,
|
||||
}
|
||||
|
||||
reader.ipv4Start, err = reader.startNode()
|
||||
|
||||
return reader, err
|
||||
}
|
||||
|
||||
func (r *Reader) startNode() (uint, error) {
|
||||
if r.Metadata.IPVersion != 6 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
nodeCount := r.Metadata.NodeCount
|
||||
|
||||
node := uint(0)
|
||||
var err error
|
||||
for i := 0; i < 96 && node < nodeCount; i++ {
|
||||
node, err = r.readNode(node, 0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// Lookup takes an IP address as a net.IP structure and a pointer to the
|
||||
// result value to Decode into.
|
||||
func (r *Reader) Lookup(ipAddress net.IP, result interface{}) error {
|
||||
pointer, err := r.lookupPointer(ipAddress)
|
||||
if pointer == 0 || err != nil {
|
||||
return err
|
||||
}
|
||||
return r.retrieveData(pointer, result)
|
||||
}
|
||||
|
||||
// LookupOffset maps an argument net.IP to a corresponding record offset in the
|
||||
// database. NotFound is returned if no such record is found, and a record may
|
||||
// otherwise be extracted by passing the returned offset to Decode. LookupOffset
|
||||
// is an advanced API, which exists to provide clients with a means to cache
|
||||
// previously-decoded records.
|
||||
func (r *Reader) LookupOffset(ipAddress net.IP) (uintptr, error) {
|
||||
pointer, err := r.lookupPointer(ipAddress)
|
||||
if pointer == 0 || err != nil {
|
||||
return NotFound, err
|
||||
}
|
||||
return r.resolveDataPointer(pointer)
|
||||
}
|
||||
|
||||
// Decode the record at |offset| into |result|. The result value pointed to
|
||||
// must be a data value that corresponds to a record in the database. This may
|
||||
// include a struct representation of the data, a map capable of holding the
|
||||
// data or an empty interface{} value.
|
||||
//
|
||||
// If result is a pointer to a struct, the struct need not include a field
|
||||
// for every value that may be in the database. If a field is not present in
|
||||
// the structure, the decoder will not decode that field, reducing the time
|
||||
// required to decode the record.
|
||||
//
|
||||
// As a special case, a struct field of type uintptr will be used to capture
|
||||
// the offset of the value. Decode may later be used to extract the stored
|
||||
// value from the offset. MaxMind DBs are highly normalized: for example in
|
||||
// the City database, all records of the same country will reference a
|
||||
// single representative record for that country. This uintptr behavior allows
|
||||
// clients to leverage this normalization in their own sub-record caching.
|
||||
func (r *Reader) Decode(offset uintptr, result interface{}) error {
|
||||
rv := reflect.ValueOf(result)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return errors.New("result param must be a pointer")
|
||||
}
|
||||
|
||||
_, err := r.decoder.decode(uint(offset), reflect.ValueOf(result))
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *Reader) lookupPointer(ipAddress net.IP) (uint, error) {
|
||||
if ipAddress == nil {
|
||||
return 0, errors.New("ipAddress passed to Lookup cannot be nil")
|
||||
}
|
||||
|
||||
ipV4Address := ipAddress.To4()
|
||||
if ipV4Address != nil {
|
||||
ipAddress = ipV4Address
|
||||
}
|
||||
if len(ipAddress) == 16 && r.Metadata.IPVersion == 4 {
|
||||
return 0, fmt.Errorf("error looking up '%s': you attempted to look up an IPv6 address in an IPv4-only database", ipAddress.String())
|
||||
}
|
||||
|
||||
return r.findAddressInTree(ipAddress)
|
||||
}
|
||||
|
||||
func (r *Reader) findAddressInTree(ipAddress net.IP) (uint, error) {
|
||||
|
||||
bitCount := uint(len(ipAddress) * 8)
|
||||
|
||||
var node uint
|
||||
if bitCount == 32 {
|
||||
node = r.ipv4Start
|
||||
}
|
||||
|
||||
nodeCount := r.Metadata.NodeCount
|
||||
|
||||
for i := uint(0); i < bitCount && node < nodeCount; i++ {
|
||||
bit := uint(1) & (uint(ipAddress[i>>3]) >> (7 - (i % 8)))
|
||||
|
||||
var err error
|
||||
node, err = r.readNode(node, bit)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if node == nodeCount {
|
||||
// Record is empty
|
||||
return 0, nil
|
||||
} else if node > nodeCount {
|
||||
return node, nil
|
||||
}
|
||||
|
||||
return 0, newInvalidDatabaseError("invalid node in search tree")
|
||||
}
|
||||
|
||||
func (r *Reader) readNode(nodeNumber uint, index uint) (uint, error) {
|
||||
RecordSize := r.Metadata.RecordSize
|
||||
|
||||
baseOffset := nodeNumber * RecordSize / 4
|
||||
|
||||
var nodeBytes []byte
|
||||
var prefix uint64
|
||||
switch RecordSize {
|
||||
case 24:
|
||||
offset := baseOffset + index*3
|
||||
nodeBytes = r.buffer[offset : offset+3]
|
||||
case 28:
|
||||
prefix = uint64(r.buffer[baseOffset+3])
|
||||
if index != 0 {
|
||||
prefix &= 0x0F
|
||||
} else {
|
||||
prefix = (0xF0 & prefix) >> 4
|
||||
}
|
||||
offset := baseOffset + index*4
|
||||
nodeBytes = r.buffer[offset : offset+3]
|
||||
case 32:
|
||||
offset := baseOffset + index*4
|
||||
nodeBytes = r.buffer[offset : offset+4]
|
||||
default:
|
||||
return 0, newInvalidDatabaseError("unknown record size: %d", RecordSize)
|
||||
}
|
||||
return uint(uintFromBytes(prefix, nodeBytes)), nil
|
||||
}
|
||||
|
||||
func (r *Reader) retrieveData(pointer uint, result interface{}) error {
|
||||
if offset, err := r.resolveDataPointer(pointer); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return r.Decode(offset, result)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reader) resolveDataPointer(pointer uint) (uintptr, error) {
|
||||
var resolved = uintptr(pointer - r.Metadata.NodeCount - dataSectionSeparatorSize)
|
||||
|
||||
if resolved > uintptr(len(r.buffer)) {
|
||||
return 0, newInvalidDatabaseError("the MaxMind DB file's search tree is corrupt")
|
||||
}
|
||||
return resolved, nil
|
||||
}
|
26
vendor/github.com/oschwald/maxminddb-golang/reader_appengine.go
generated
vendored
Normal file
26
vendor/github.com/oschwald/maxminddb-golang/reader_appengine.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// +build appengine
|
||||
|
||||
package maxminddb
|
||||
|
||||
import "io/ioutil"
|
||||
|
||||
// Open takes a string path to a MaxMind DB file and returns a Reader
|
||||
// structure or an error. The database file is opened using a memory map,
|
||||
// except on Google App Engine where mmap is not supported; there the database
|
||||
// is loaded into memory. Use the Close method on the Reader object to return
|
||||
// the resources to the system.
|
||||
func Open(file string) (*Reader, error) {
|
||||
bytes, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return FromBytes(bytes)
|
||||
}
|
||||
|
||||
// Close unmaps the database file from virtual memory and returns the
|
||||
// resources to the system. If called on a Reader opened using FromBytes
|
||||
// or Open on Google App Engine, this method does nothing.
|
||||
func (r *Reader) Close() error {
|
||||
return nil
|
||||
}
|
56
vendor/github.com/oschwald/maxminddb-golang/reader_other.go
generated
vendored
Normal file
56
vendor/github.com/oschwald/maxminddb-golang/reader_other.go
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
// +build !appengine
|
||||
|
||||
package maxminddb
|
||||
|
||||
import "os"
|
||||
|
||||
// Open takes a string path to a MaxMind DB file and returns a Reader
|
||||
// structure or an error. The database file is opened using a memory map,
|
||||
// except on Google App Engine where mmap is not supported; there the database
|
||||
// is loaded into memory. Use the Close method on the Reader object to return
|
||||
// the resources to the system.
|
||||
func Open(file string) (*Reader, error) {
|
||||
mapFile, err := os.Open(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if rerr := mapFile.Close(); rerr != nil {
|
||||
err = rerr
|
||||
}
|
||||
}()
|
||||
|
||||
stats, err := mapFile.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fileSize := int(stats.Size())
|
||||
mmap, err := mmap(int(mapFile.Fd()), fileSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reader, err := FromBytes(mmap)
|
||||
if err != nil {
|
||||
if err2 := munmap(mmap); err2 != nil {
|
||||
// failing to unmap the file is probably the more severe error
|
||||
return nil, err2
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reader.hasMappedFile = true
|
||||
return reader, err
|
||||
}
|
||||
|
||||
// Close unmaps the database file from virtual memory and returns the
|
||||
// resources to the system. If called on a Reader opened using FromBytes
|
||||
// or Open on Google App Engine, this method does nothing.
|
||||
func (r *Reader) Close() (err error) {
|
||||
if r.hasMappedFile {
|
||||
err = munmap(r.buffer)
|
||||
r.hasMappedFile = false
|
||||
}
|
||||
return err
|
||||
}
|
108
vendor/github.com/oschwald/maxminddb-golang/traverse.go
generated
vendored
Normal file
108
vendor/github.com/oschwald/maxminddb-golang/traverse.go
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
package maxminddb
|
||||
|
||||
import "net"
|
||||
|
||||
// Internal structure used to keep track of nodes we still need to visit.
|
||||
type netNode struct {
|
||||
ip net.IP
|
||||
bit uint
|
||||
pointer uint
|
||||
}
|
||||
|
||||
// Networks represents a set of subnets that we are iterating over.
|
||||
type Networks struct {
|
||||
reader *Reader
|
||||
nodes []netNode // Nodes we still have to visit.
|
||||
lastNode netNode
|
||||
err error
|
||||
}
|
||||
|
||||
// Networks returns an iterator that can be used to traverse all networks in
|
||||
// the database.
|
||||
//
|
||||
// Please note that a MaxMind DB may map IPv4 networks into several locations
|
||||
// in in an IPv6 database. This iterator will iterate over all of these
|
||||
// locations separately.
|
||||
func (r *Reader) Networks() *Networks {
|
||||
s := 4
|
||||
if r.Metadata.IPVersion == 6 {
|
||||
s = 16
|
||||
}
|
||||
return &Networks{
|
||||
reader: r,
|
||||
nodes: []netNode{
|
||||
netNode{
|
||||
ip: make(net.IP, s),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Next prepares the next network for reading with the Network method. It
|
||||
// returns true if there is another network to be processed and false if there
|
||||
// are no more networks or if there is an error.
|
||||
func (n *Networks) Next() bool {
|
||||
for len(n.nodes) > 0 {
|
||||
node := n.nodes[len(n.nodes)-1]
|
||||
n.nodes = n.nodes[:len(n.nodes)-1]
|
||||
|
||||
for {
|
||||
if node.pointer < n.reader.Metadata.NodeCount {
|
||||
ipRight := make(net.IP, len(node.ip))
|
||||
copy(ipRight, node.ip)
|
||||
if len(ipRight) <= int(node.bit>>3) {
|
||||
n.err = newInvalidDatabaseError(
|
||||
"invalid search tree at %v/%v", ipRight, node.bit)
|
||||
return false
|
||||
}
|
||||
ipRight[node.bit>>3] |= 1 << uint(7-(node.bit%8))
|
||||
|
||||
rightPointer, err := n.reader.readNode(node.pointer, 1)
|
||||
if err != nil {
|
||||
n.err = err
|
||||
return false
|
||||
}
|
||||
|
||||
node.bit++
|
||||
n.nodes = append(n.nodes, netNode{
|
||||
pointer: rightPointer,
|
||||
ip: ipRight,
|
||||
bit: node.bit,
|
||||
})
|
||||
|
||||
node.pointer, err = n.reader.readNode(node.pointer, 0)
|
||||
if err != nil {
|
||||
n.err = err
|
||||
return false
|
||||
}
|
||||
|
||||
} else if node.pointer > n.reader.Metadata.NodeCount {
|
||||
n.lastNode = node
|
||||
return true
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// Network returns the current network or an error if there is a problem
|
||||
// decoding the data for the network. It takes a pointer to a result value to
|
||||
// decode the network's data into.
|
||||
func (n *Networks) Network(result interface{}) (*net.IPNet, error) {
|
||||
if err := n.reader.retrieveData(n.lastNode.pointer, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &net.IPNet{
|
||||
IP: n.lastNode.ip,
|
||||
Mask: net.CIDRMask(int(n.lastNode.bit), len(n.lastNode.ip)*8),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Err returns an error, if any, that was encountered during iteration.
|
||||
func (n *Networks) Err() error {
|
||||
return n.err
|
||||
}
|
185
vendor/github.com/oschwald/maxminddb-golang/verifier.go
generated
vendored
Normal file
185
vendor/github.com/oschwald/maxminddb-golang/verifier.go
generated
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
package maxminddb
|
||||
|
||||
import "reflect"
|
||||
|
||||
type verifier struct {
|
||||
reader *Reader
|
||||
}
|
||||
|
||||
// Verify checks that the database is valid. It validates the search tree,
|
||||
// the data section, and the metadata section. This verifier is stricter than
|
||||
// the specification and may return errors on databases that are readable.
|
||||
func (r *Reader) Verify() error {
|
||||
v := verifier{r}
|
||||
if err := v.verifyMetadata(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return v.verifyDatabase()
|
||||
}
|
||||
|
||||
func (v *verifier) verifyMetadata() error {
|
||||
metadata := v.reader.Metadata
|
||||
|
||||
if metadata.BinaryFormatMajorVersion != 2 {
|
||||
return testError(
|
||||
"binary_format_major_version",
|
||||
2,
|
||||
metadata.BinaryFormatMajorVersion,
|
||||
)
|
||||
}
|
||||
|
||||
if metadata.BinaryFormatMinorVersion != 0 {
|
||||
return testError(
|
||||
"binary_format_minor_version",
|
||||
0,
|
||||
metadata.BinaryFormatMinorVersion,
|
||||
)
|
||||
}
|
||||
|
||||
if metadata.DatabaseType == "" {
|
||||
return testError(
|
||||
"database_type",
|
||||
"non-empty string",
|
||||
metadata.DatabaseType,
|
||||
)
|
||||
}
|
||||
|
||||
if len(metadata.Description) == 0 {
|
||||
return testError(
|
||||
"description",
|
||||
"non-empty slice",
|
||||
metadata.Description,
|
||||
)
|
||||
}
|
||||
|
||||
if metadata.IPVersion != 4 && metadata.IPVersion != 6 {
|
||||
return testError(
|
||||
"ip_version",
|
||||
"4 or 6",
|
||||
metadata.IPVersion,
|
||||
)
|
||||
}
|
||||
|
||||
if metadata.RecordSize != 24 &&
|
||||
metadata.RecordSize != 28 &&
|
||||
metadata.RecordSize != 32 {
|
||||
return testError(
|
||||
"record_size",
|
||||
"24, 28, or 32",
|
||||
metadata.RecordSize,
|
||||
)
|
||||
}
|
||||
|
||||
if metadata.NodeCount == 0 {
|
||||
return testError(
|
||||
"node_count",
|
||||
"positive integer",
|
||||
metadata.NodeCount,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifier) verifyDatabase() error {
|
||||
offsets, err := v.verifySearchTree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := v.verifyDataSectionSeparator(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return v.verifyDataSection(offsets)
|
||||
}
|
||||
|
||||
func (v *verifier) verifySearchTree() (map[uint]bool, error) {
|
||||
offsets := make(map[uint]bool)
|
||||
|
||||
it := v.reader.Networks()
|
||||
for it.Next() {
|
||||
offset, err := v.reader.resolveDataPointer(it.lastNode.pointer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
offsets[uint(offset)] = true
|
||||
}
|
||||
if err := it.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return offsets, nil
|
||||
}
|
||||
|
||||
func (v *verifier) verifyDataSectionSeparator() error {
|
||||
separatorStart := v.reader.Metadata.NodeCount * v.reader.Metadata.RecordSize / 4
|
||||
|
||||
separator := v.reader.buffer[separatorStart : separatorStart+dataSectionSeparatorSize]
|
||||
|
||||
for _, b := range separator {
|
||||
if b != 0 {
|
||||
return newInvalidDatabaseError("unexpected byte in data separator: %v", separator)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifier) verifyDataSection(offsets map[uint]bool) error {
|
||||
pointerCount := len(offsets)
|
||||
|
||||
decoder := v.reader.decoder
|
||||
|
||||
var offset uint
|
||||
bufferLen := uint(len(decoder.buffer))
|
||||
for offset < bufferLen {
|
||||
var data interface{}
|
||||
rv := reflect.ValueOf(&data)
|
||||
newOffset, err := decoder.decode(offset, rv)
|
||||
if err != nil {
|
||||
return newInvalidDatabaseError("received decoding error (%v) at offset of %v", err, offset)
|
||||
}
|
||||
if newOffset <= offset {
|
||||
return newInvalidDatabaseError("data section offset unexpectedly went from %v to %v", offset, newOffset)
|
||||
}
|
||||
|
||||
pointer := offset
|
||||
|
||||
if _, ok := offsets[pointer]; ok {
|
||||
delete(offsets, pointer)
|
||||
} else {
|
||||
return newInvalidDatabaseError("found data (%v) at %v that the search tree does not point to", data, pointer)
|
||||
}
|
||||
|
||||
offset = newOffset
|
||||
}
|
||||
|
||||
if offset != bufferLen {
|
||||
return newInvalidDatabaseError(
|
||||
"unexpected data at the end of the data section (last offset: %v, end: %v)",
|
||||
offset,
|
||||
bufferLen,
|
||||
)
|
||||
}
|
||||
|
||||
if len(offsets) != 0 {
|
||||
return newInvalidDatabaseError(
|
||||
"found %v pointers (of %v) in the search tree that we did not see in the data section",
|
||||
len(offsets),
|
||||
pointerCount,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testError(
|
||||
field string,
|
||||
expected interface{},
|
||||
actual interface{},
|
||||
) error {
|
||||
return newInvalidDatabaseError(
|
||||
"%v - Expected: %v Actual: %v",
|
||||
field,
|
||||
expected,
|
||||
actual,
|
||||
)
|
||||
}
|
27
vendor/golang.org/x/net/route/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/net/route/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
269
vendor/golang.org/x/net/route/address.go
generated
vendored
Normal file
269
vendor/golang.org/x/net/route/address.go
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
import "runtime"
|
||||
|
||||
// An Addr represents an address associated with packet routing.
|
||||
type Addr interface {
|
||||
// Family returns an address family.
|
||||
Family() int
|
||||
}
|
||||
|
||||
// A LinkAddr represents a link-layer address.
|
||||
type LinkAddr struct {
|
||||
Index int // interface index when attached
|
||||
Name string // interface name when attached
|
||||
Addr []byte // link-layer address when attached
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *LinkAddr) Family() int { return sysAF_LINK }
|
||||
|
||||
func parseLinkAddr(b []byte) (Addr, error) {
|
||||
if len(b) < 8 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
_, a, err := parseKernelLinkAddr(sysAF_LINK, b[4:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.(*LinkAddr).Index = int(nativeEndian.Uint16(b[2:4]))
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// parseKernelLinkAddr parses b as a link-layer address in
|
||||
// conventional BSD kernel form.
|
||||
func parseKernelLinkAddr(_ int, b []byte) (int, Addr, error) {
|
||||
// The encoding looks like the following:
|
||||
// +----------------------------+
|
||||
// | Type (1 octet) |
|
||||
// +----------------------------+
|
||||
// | Name length (1 octet) |
|
||||
// +----------------------------+
|
||||
// | Address length (1 octet) |
|
||||
// +----------------------------+
|
||||
// | Selector length (1 octet) |
|
||||
// +----------------------------+
|
||||
// | Data (variable) |
|
||||
// +----------------------------+
|
||||
//
|
||||
// On some platforms, all-bit-one of length field means "don't
|
||||
// care".
|
||||
nlen, alen, slen := int(b[1]), int(b[2]), int(b[3])
|
||||
if nlen == 0xff {
|
||||
nlen = 0
|
||||
}
|
||||
if alen == 0xff {
|
||||
alen = 0
|
||||
}
|
||||
if slen == 0xff {
|
||||
slen = 0
|
||||
}
|
||||
l := 4 + nlen + alen + slen
|
||||
if len(b) < l {
|
||||
return 0, nil, errInvalidAddr
|
||||
}
|
||||
data := b[4:]
|
||||
var name string
|
||||
var addr []byte
|
||||
if nlen > 0 {
|
||||
name = string(data[:nlen])
|
||||
data = data[nlen:]
|
||||
}
|
||||
if alen > 0 {
|
||||
addr = data[:alen]
|
||||
data = data[alen:]
|
||||
}
|
||||
return l, &LinkAddr{Name: name, Addr: addr}, nil
|
||||
}
|
||||
|
||||
// An Inet4Addr represents an internet address for IPv4.
|
||||
type Inet4Addr struct {
|
||||
IP [4]byte // IP address
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *Inet4Addr) Family() int { return sysAF_INET }
|
||||
|
||||
// An Inet6Addr represents an internet address for IPv6.
|
||||
type Inet6Addr struct {
|
||||
IP [16]byte // IP address
|
||||
ZoneID int // zone identifier
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *Inet6Addr) Family() int { return sysAF_INET6 }
|
||||
|
||||
// parseInetAddr parses b as an internet address for IPv4 or IPv6.
|
||||
func parseInetAddr(af int, b []byte) (Addr, error) {
|
||||
switch af {
|
||||
case sysAF_INET:
|
||||
if len(b) < 16 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
a := &Inet4Addr{}
|
||||
copy(a.IP[:], b[4:8])
|
||||
return a, nil
|
||||
case sysAF_INET6:
|
||||
if len(b) < 28 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
a := &Inet6Addr{ZoneID: int(nativeEndian.Uint32(b[24:28]))}
|
||||
copy(a.IP[:], b[8:24])
|
||||
if a.IP[0] == 0xfe && a.IP[1]&0xc0 == 0x80 || a.IP[0] == 0xff && (a.IP[1]&0x0f == 0x01 || a.IP[1]&0x0f == 0x02) {
|
||||
// KAME based IPv6 protocol stack usually
|
||||
// embeds the interface index in the
|
||||
// interface-local or link-local address as
|
||||
// the kernel-internal form.
|
||||
id := int(bigEndian.Uint16(a.IP[2:4]))
|
||||
if id != 0 {
|
||||
a.ZoneID = id
|
||||
a.IP[2], a.IP[3] = 0, 0
|
||||
}
|
||||
}
|
||||
return a, nil
|
||||
default:
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
}
|
||||
|
||||
// parseKernelInetAddr parses b as an internet address in conventional
|
||||
// BSD kernel form.
|
||||
func parseKernelInetAddr(af int, b []byte) (int, Addr, error) {
|
||||
// The encoding looks similar to the NLRI encoding.
|
||||
// +----------------------------+
|
||||
// | Length (1 octet) |
|
||||
// +----------------------------+
|
||||
// | Address prefix (variable) |
|
||||
// +----------------------------+
|
||||
//
|
||||
// The differences between the kernel form and the NLRI
|
||||
// encoding are:
|
||||
//
|
||||
// - The length field of the kernel form indicates the prefix
|
||||
// length in bytes, not in bits
|
||||
//
|
||||
// - In the kernel form, zero value of the length field
|
||||
// doesn't mean 0.0.0.0/0 or ::/0
|
||||
//
|
||||
// - The kernel form appends leading bytes to the prefix field
|
||||
// to make the <length, prefix> tuple to be conformed with
|
||||
// the routing message boundary
|
||||
l := int(b[0])
|
||||
if runtime.GOOS == "darwin" {
|
||||
// On Darwn, an address in the kernel form is also
|
||||
// used as a message filler.
|
||||
if l == 0 || len(b) > roundup(l) {
|
||||
l = roundup(l)
|
||||
}
|
||||
} else {
|
||||
l = roundup(l)
|
||||
}
|
||||
if len(b) < l {
|
||||
return 0, nil, errInvalidAddr
|
||||
}
|
||||
// Don't reorder case expressions.
|
||||
// The case expressions for IPv6 must come first.
|
||||
const (
|
||||
off4 = 4 // offset of in_addr
|
||||
off6 = 8 // offset of in6_addr
|
||||
)
|
||||
switch {
|
||||
case b[0] == 28: // size of sockaddr_in6
|
||||
a := &Inet6Addr{}
|
||||
copy(a.IP[:], b[off6:off6+16])
|
||||
return int(b[0]), a, nil
|
||||
case af == sysAF_INET6:
|
||||
a := &Inet6Addr{}
|
||||
if l-1 < off6 {
|
||||
copy(a.IP[:], b[1:l])
|
||||
} else {
|
||||
copy(a.IP[:], b[l-off6:l])
|
||||
}
|
||||
return int(b[0]), a, nil
|
||||
case b[0] == 16: // size of sockaddr_in
|
||||
a := &Inet4Addr{}
|
||||
copy(a.IP[:], b[off4:off4+4])
|
||||
return int(b[0]), a, nil
|
||||
default: // an old fashion, AF_UNSPEC or unknown means AF_INET
|
||||
a := &Inet4Addr{}
|
||||
if l-1 < off4 {
|
||||
copy(a.IP[:], b[1:l])
|
||||
} else {
|
||||
copy(a.IP[:], b[l-off4:l])
|
||||
}
|
||||
return int(b[0]), a, nil
|
||||
}
|
||||
}
|
||||
|
||||
// A DefaultAddr represents an address of various operating
|
||||
// system-specific features.
|
||||
type DefaultAddr struct {
|
||||
af int
|
||||
Raw []byte // raw format of address
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *DefaultAddr) Family() int { return a.af }
|
||||
|
||||
func parseDefaultAddr(b []byte) (Addr, error) {
|
||||
if len(b) < 2 || len(b) < int(b[0]) {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
a := &DefaultAddr{af: int(b[1]), Raw: b[:b[0]]}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) ([]Addr, error) {
|
||||
var as [sysRTAX_MAX]Addr
|
||||
af := int(sysAF_UNSPEC)
|
||||
for i := uint(0); i < sysRTAX_MAX && len(b) >= roundup(0); i++ {
|
||||
if attrs&(1<<i) == 0 {
|
||||
continue
|
||||
}
|
||||
if i <= sysRTAX_BRD {
|
||||
switch b[1] {
|
||||
case sysAF_LINK:
|
||||
a, err := parseLinkAddr(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
as[i] = a
|
||||
b = b[roundup(int(b[0])):]
|
||||
case sysAF_INET, sysAF_INET6:
|
||||
af = int(b[1])
|
||||
a, err := parseInetAddr(af, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
as[i] = a
|
||||
b = b[roundup(int(b[0])):]
|
||||
default:
|
||||
l, a, err := fn(af, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
as[i] = a
|
||||
ll := roundup(l)
|
||||
if len(b) < ll {
|
||||
b = b[l:]
|
||||
} else {
|
||||
b = b[ll:]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a, err := parseDefaultAddr(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
as[i] = a
|
||||
b = b[roundup(int(b[0])):]
|
||||
}
|
||||
}
|
||||
return as[:], nil
|
||||
}
|
90
vendor/golang.org/x/net/route/binary.go
generated
vendored
Normal file
90
vendor/golang.org/x/net/route/binary.go
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
// This file contains duplicates of encoding/binary package.
|
||||
//
|
||||
// This package is supposed to be used by the net package of standard
|
||||
// library. Therefore a package set used in the package must be the
|
||||
// same as net package.
|
||||
|
||||
var (
|
||||
littleEndian binaryLittleEndian
|
||||
bigEndian binaryBigEndian
|
||||
)
|
||||
|
||||
type binaryByteOrder interface {
|
||||
Uint16([]byte) uint16
|
||||
Uint32([]byte) uint32
|
||||
PutUint16([]byte, uint16)
|
||||
PutUint32([]byte, uint32)
|
||||
Uint64([]byte) uint64
|
||||
}
|
||||
|
||||
type binaryLittleEndian struct{}
|
||||
|
||||
func (binaryLittleEndian) Uint16(b []byte) uint16 {
|
||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint16(b[0]) | uint16(b[1])<<8
|
||||
}
|
||||
|
||||
func (binaryLittleEndian) PutUint16(b []byte, v uint16) {
|
||||
_ = b[1] // early bounds check to guarantee safety of writes below
|
||||
b[0] = byte(v)
|
||||
b[1] = byte(v >> 8)
|
||||
}
|
||||
|
||||
func (binaryLittleEndian) Uint32(b []byte) uint32 {
|
||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
|
||||
}
|
||||
|
||||
func (binaryLittleEndian) PutUint32(b []byte, v uint32) {
|
||||
_ = b[3] // early bounds check to guarantee safety of writes below
|
||||
b[0] = byte(v)
|
||||
b[1] = byte(v >> 8)
|
||||
b[2] = byte(v >> 16)
|
||||
b[3] = byte(v >> 24)
|
||||
}
|
||||
|
||||
func (binaryLittleEndian) Uint64(b []byte) uint64 {
|
||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
||||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
||||
}
|
||||
|
||||
type binaryBigEndian struct{}
|
||||
|
||||
func (binaryBigEndian) Uint16(b []byte) uint16 {
|
||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint16(b[1]) | uint16(b[0])<<8
|
||||
}
|
||||
|
||||
func (binaryBigEndian) PutUint16(b []byte, v uint16) {
|
||||
_ = b[1] // early bounds check to guarantee safety of writes below
|
||||
b[0] = byte(v >> 8)
|
||||
b[1] = byte(v)
|
||||
}
|
||||
|
||||
func (binaryBigEndian) Uint32(b []byte) uint32 {
|
||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
|
||||
}
|
||||
|
||||
func (binaryBigEndian) PutUint32(b []byte, v uint32) {
|
||||
_ = b[3] // early bounds check to guarantee safety of writes below
|
||||
b[0] = byte(v >> 24)
|
||||
b[1] = byte(v >> 16)
|
||||
b[2] = byte(v >> 8)
|
||||
b[3] = byte(v)
|
||||
}
|
||||
|
||||
func (binaryBigEndian) Uint64(b []byte) uint64 {
|
||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
||||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
||||
}
|
106
vendor/golang.org/x/net/route/defs_darwin.go
generated
vendored
Normal file
106
vendor/golang.org/x/net/route/defs_darwin.go
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = C.AF_UNSPEC
|
||||
sysAF_INET = C.AF_INET
|
||||
sysAF_ROUTE = C.AF_ROUTE
|
||||
sysAF_LINK = C.AF_LINK
|
||||
sysAF_INET6 = C.AF_INET6
|
||||
|
||||
sysNET_RT_DUMP = C.NET_RT_DUMP
|
||||
sysNET_RT_FLAGS = C.NET_RT_FLAGS
|
||||
sysNET_RT_IFLIST = C.NET_RT_IFLIST
|
||||
sysNET_RT_STAT = C.NET_RT_STAT
|
||||
sysNET_RT_TRASH = C.NET_RT_TRASH
|
||||
sysNET_RT_IFLIST2 = C.NET_RT_IFLIST2
|
||||
sysNET_RT_DUMP2 = C.NET_RT_DUMP2
|
||||
sysNET_RT_MAXID = C.NET_RT_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = C.CTL_MAXNAME
|
||||
|
||||
sysCTL_UNSPEC = C.CTL_UNSPEC
|
||||
sysCTL_KERN = C.CTL_KERN
|
||||
sysCTL_VM = C.CTL_VM
|
||||
sysCTL_VFS = C.CTL_VFS
|
||||
sysCTL_NET = C.CTL_NET
|
||||
sysCTL_DEBUG = C.CTL_DEBUG
|
||||
sysCTL_HW = C.CTL_HW
|
||||
sysCTL_MACHDEP = C.CTL_MACHDEP
|
||||
sysCTL_USER = C.CTL_USER
|
||||
sysCTL_MAXID = C.CTL_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = C.RTM_VERSION
|
||||
|
||||
sysRTM_ADD = C.RTM_ADD
|
||||
sysRTM_DELETE = C.RTM_DELETE
|
||||
sysRTM_CHANGE = C.RTM_CHANGE
|
||||
sysRTM_GET = C.RTM_GET
|
||||
sysRTM_LOSING = C.RTM_LOSING
|
||||
sysRTM_REDIRECT = C.RTM_REDIRECT
|
||||
sysRTM_MISS = C.RTM_MISS
|
||||
sysRTM_LOCK = C.RTM_LOCK
|
||||
sysRTM_OLDADD = C.RTM_OLDADD
|
||||
sysRTM_OLDDEL = C.RTM_OLDDEL
|
||||
sysRTM_RESOLVE = C.RTM_RESOLVE
|
||||
sysRTM_NEWADDR = C.RTM_NEWADDR
|
||||
sysRTM_DELADDR = C.RTM_DELADDR
|
||||
sysRTM_IFINFO = C.RTM_IFINFO
|
||||
sysRTM_NEWMADDR = C.RTM_NEWMADDR
|
||||
sysRTM_DELMADDR = C.RTM_DELMADDR
|
||||
sysRTM_IFINFO2 = C.RTM_IFINFO2
|
||||
sysRTM_NEWMADDR2 = C.RTM_NEWMADDR2
|
||||
sysRTM_GET2 = C.RTM_GET2
|
||||
|
||||
sysRTA_DST = C.RTA_DST
|
||||
sysRTA_GATEWAY = C.RTA_GATEWAY
|
||||
sysRTA_NETMASK = C.RTA_NETMASK
|
||||
sysRTA_GENMASK = C.RTA_GENMASK
|
||||
sysRTA_IFP = C.RTA_IFP
|
||||
sysRTA_IFA = C.RTA_IFA
|
||||
sysRTA_AUTHOR = C.RTA_AUTHOR
|
||||
sysRTA_BRD = C.RTA_BRD
|
||||
|
||||
sysRTAX_DST = C.RTAX_DST
|
||||
sysRTAX_GATEWAY = C.RTAX_GATEWAY
|
||||
sysRTAX_NETMASK = C.RTAX_NETMASK
|
||||
sysRTAX_GENMASK = C.RTAX_GENMASK
|
||||
sysRTAX_IFP = C.RTAX_IFP
|
||||
sysRTAX_IFA = C.RTAX_IFA
|
||||
sysRTAX_AUTHOR = C.RTAX_AUTHOR
|
||||
sysRTAX_BRD = C.RTAX_BRD
|
||||
sysRTAX_MAX = C.RTAX_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDarwin15 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrDarwin15 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfmaMsghdrDarwin15 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfMsghdr2Darwin15 = C.sizeof_struct_if_msghdr2
|
||||
sizeofIfmaMsghdr2Darwin15 = C.sizeof_struct_ifma_msghdr2
|
||||
sizeofIfDataDarwin15 = C.sizeof_struct_if_data
|
||||
sizeofIfData64Darwin15 = C.sizeof_struct_if_data64
|
||||
|
||||
sizeofRtMsghdrDarwin15 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMsghdr2Darwin15 = C.sizeof_struct_rt_msghdr2
|
||||
sizeofRtMetricsDarwin15 = C.sizeof_struct_rt_metrics
|
||||
)
|
105
vendor/golang.org/x/net/route/defs_dragonfly.go
generated
vendored
Normal file
105
vendor/golang.org/x/net/route/defs_dragonfly.go
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = C.AF_UNSPEC
|
||||
sysAF_INET = C.AF_INET
|
||||
sysAF_ROUTE = C.AF_ROUTE
|
||||
sysAF_LINK = C.AF_LINK
|
||||
sysAF_INET6 = C.AF_INET6
|
||||
|
||||
sysNET_RT_DUMP = C.NET_RT_DUMP
|
||||
sysNET_RT_FLAGS = C.NET_RT_FLAGS
|
||||
sysNET_RT_IFLIST = C.NET_RT_IFLIST
|
||||
sysNET_RT_MAXID = C.NET_RT_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = C.CTL_MAXNAME
|
||||
|
||||
sysCTL_UNSPEC = C.CTL_UNSPEC
|
||||
sysCTL_KERN = C.CTL_KERN
|
||||
sysCTL_VM = C.CTL_VM
|
||||
sysCTL_VFS = C.CTL_VFS
|
||||
sysCTL_NET = C.CTL_NET
|
||||
sysCTL_DEBUG = C.CTL_DEBUG
|
||||
sysCTL_HW = C.CTL_HW
|
||||
sysCTL_MACHDEP = C.CTL_MACHDEP
|
||||
sysCTL_USER = C.CTL_USER
|
||||
sysCTL_P1003_1B = C.CTL_P1003_1B
|
||||
sysCTL_LWKT = C.CTL_LWKT
|
||||
sysCTL_MAXID = C.CTL_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = C.RTM_VERSION
|
||||
|
||||
sysRTM_ADD = C.RTM_ADD
|
||||
sysRTM_DELETE = C.RTM_DELETE
|
||||
sysRTM_CHANGE = C.RTM_CHANGE
|
||||
sysRTM_GET = C.RTM_GET
|
||||
sysRTM_LOSING = C.RTM_LOSING
|
||||
sysRTM_REDIRECT = C.RTM_REDIRECT
|
||||
sysRTM_MISS = C.RTM_MISS
|
||||
sysRTM_LOCK = C.RTM_LOCK
|
||||
sysRTM_OLDADD = C.RTM_OLDADD
|
||||
sysRTM_OLDDEL = C.RTM_OLDDEL
|
||||
sysRTM_RESOLVE = C.RTM_RESOLVE
|
||||
sysRTM_NEWADDR = C.RTM_NEWADDR
|
||||
sysRTM_DELADDR = C.RTM_DELADDR
|
||||
sysRTM_IFINFO = C.RTM_IFINFO
|
||||
sysRTM_NEWMADDR = C.RTM_NEWMADDR
|
||||
sysRTM_DELMADDR = C.RTM_DELMADDR
|
||||
sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE
|
||||
sysRTM_IEEE80211 = C.RTM_IEEE80211
|
||||
|
||||
sysRTA_DST = C.RTA_DST
|
||||
sysRTA_GATEWAY = C.RTA_GATEWAY
|
||||
sysRTA_NETMASK = C.RTA_NETMASK
|
||||
sysRTA_GENMASK = C.RTA_GENMASK
|
||||
sysRTA_IFP = C.RTA_IFP
|
||||
sysRTA_IFA = C.RTA_IFA
|
||||
sysRTA_AUTHOR = C.RTA_AUTHOR
|
||||
sysRTA_BRD = C.RTA_BRD
|
||||
sysRTA_MPLS1 = C.RTA_MPLS1
|
||||
sysRTA_MPLS2 = C.RTA_MPLS2
|
||||
sysRTA_MPLS3 = C.RTA_MPLS3
|
||||
|
||||
sysRTAX_DST = C.RTAX_DST
|
||||
sysRTAX_GATEWAY = C.RTAX_GATEWAY
|
||||
sysRTAX_NETMASK = C.RTAX_NETMASK
|
||||
sysRTAX_GENMASK = C.RTAX_GENMASK
|
||||
sysRTAX_IFP = C.RTAX_IFP
|
||||
sysRTAX_IFA = C.RTAX_IFA
|
||||
sysRTAX_AUTHOR = C.RTAX_AUTHOR
|
||||
sysRTAX_BRD = C.RTAX_BRD
|
||||
sysRTAX_MPLS1 = C.RTAX_MPLS1
|
||||
sysRTAX_MPLS2 = C.RTAX_MPLS2
|
||||
sysRTAX_MPLS3 = C.RTAX_MPLS3
|
||||
sysRTAX_MAX = C.RTAX_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDragonFlyBSD4 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfmaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrDragonFlyBSD4 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrDragonFlyBSD4 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsDragonFlyBSD4 = C.sizeof_struct_rt_metrics
|
||||
)
|
329
vendor/golang.org/x/net/route/defs_freebsd.go
generated
vendored
Normal file
329
vendor/golang.org/x/net/route/defs_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,329 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
|
||||
struct if_data_freebsd7 {
|
||||
u_char ifi_type;
|
||||
u_char ifi_physical;
|
||||
u_char ifi_addrlen;
|
||||
u_char ifi_hdrlen;
|
||||
u_char ifi_link_state;
|
||||
u_char ifi_spare_char1;
|
||||
u_char ifi_spare_char2;
|
||||
u_char ifi_datalen;
|
||||
u_long ifi_mtu;
|
||||
u_long ifi_metric;
|
||||
u_long ifi_baudrate;
|
||||
u_long ifi_ipackets;
|
||||
u_long ifi_ierrors;
|
||||
u_long ifi_opackets;
|
||||
u_long ifi_oerrors;
|
||||
u_long ifi_collisions;
|
||||
u_long ifi_ibytes;
|
||||
u_long ifi_obytes;
|
||||
u_long ifi_imcasts;
|
||||
u_long ifi_omcasts;
|
||||
u_long ifi_iqdrops;
|
||||
u_long ifi_noproto;
|
||||
u_long ifi_hwassist;
|
||||
time_t __ifi_epoch;
|
||||
struct timeval __ifi_lastchange;
|
||||
};
|
||||
|
||||
struct if_data_freebsd8 {
|
||||
u_char ifi_type;
|
||||
u_char ifi_physical;
|
||||
u_char ifi_addrlen;
|
||||
u_char ifi_hdrlen;
|
||||
u_char ifi_link_state;
|
||||
u_char ifi_spare_char1;
|
||||
u_char ifi_spare_char2;
|
||||
u_char ifi_datalen;
|
||||
u_long ifi_mtu;
|
||||
u_long ifi_metric;
|
||||
u_long ifi_baudrate;
|
||||
u_long ifi_ipackets;
|
||||
u_long ifi_ierrors;
|
||||
u_long ifi_opackets;
|
||||
u_long ifi_oerrors;
|
||||
u_long ifi_collisions;
|
||||
u_long ifi_ibytes;
|
||||
u_long ifi_obytes;
|
||||
u_long ifi_imcasts;
|
||||
u_long ifi_omcasts;
|
||||
u_long ifi_iqdrops;
|
||||
u_long ifi_noproto;
|
||||
u_long ifi_hwassist;
|
||||
time_t __ifi_epoch;
|
||||
struct timeval __ifi_lastchange;
|
||||
};
|
||||
|
||||
struct if_data_freebsd9 {
|
||||
u_char ifi_type;
|
||||
u_char ifi_physical;
|
||||
u_char ifi_addrlen;
|
||||
u_char ifi_hdrlen;
|
||||
u_char ifi_link_state;
|
||||
u_char ifi_spare_char1;
|
||||
u_char ifi_spare_char2;
|
||||
u_char ifi_datalen;
|
||||
u_long ifi_mtu;
|
||||
u_long ifi_metric;
|
||||
u_long ifi_baudrate;
|
||||
u_long ifi_ipackets;
|
||||
u_long ifi_ierrors;
|
||||
u_long ifi_opackets;
|
||||
u_long ifi_oerrors;
|
||||
u_long ifi_collisions;
|
||||
u_long ifi_ibytes;
|
||||
u_long ifi_obytes;
|
||||
u_long ifi_imcasts;
|
||||
u_long ifi_omcasts;
|
||||
u_long ifi_iqdrops;
|
||||
u_long ifi_noproto;
|
||||
u_long ifi_hwassist;
|
||||
time_t __ifi_epoch;
|
||||
struct timeval __ifi_lastchange;
|
||||
};
|
||||
|
||||
struct if_data_freebsd10 {
|
||||
u_char ifi_type;
|
||||
u_char ifi_physical;
|
||||
u_char ifi_addrlen;
|
||||
u_char ifi_hdrlen;
|
||||
u_char ifi_link_state;
|
||||
u_char ifi_vhid;
|
||||
u_char ifi_baudrate_pf;
|
||||
u_char ifi_datalen;
|
||||
u_long ifi_mtu;
|
||||
u_long ifi_metric;
|
||||
u_long ifi_baudrate;
|
||||
u_long ifi_ipackets;
|
||||
u_long ifi_ierrors;
|
||||
u_long ifi_opackets;
|
||||
u_long ifi_oerrors;
|
||||
u_long ifi_collisions;
|
||||
u_long ifi_ibytes;
|
||||
u_long ifi_obytes;
|
||||
u_long ifi_imcasts;
|
||||
u_long ifi_omcasts;
|
||||
u_long ifi_iqdrops;
|
||||
u_long ifi_noproto;
|
||||
uint64_t ifi_hwassist;
|
||||
time_t __ifi_epoch;
|
||||
struct timeval __ifi_lastchange;
|
||||
};
|
||||
|
||||
struct if_data_freebsd11 {
|
||||
uint8_t ifi_type;
|
||||
uint8_t ifi_physical;
|
||||
uint8_t ifi_addrlen;
|
||||
uint8_t ifi_hdrlen;
|
||||
uint8_t ifi_link_state;
|
||||
uint8_t ifi_vhid;
|
||||
uint16_t ifi_datalen;
|
||||
uint32_t ifi_mtu;
|
||||
uint32_t ifi_metric;
|
||||
uint64_t ifi_baudrate;
|
||||
uint64_t ifi_ipackets;
|
||||
uint64_t ifi_ierrors;
|
||||
uint64_t ifi_opackets;
|
||||
uint64_t ifi_oerrors;
|
||||
uint64_t ifi_collisions;
|
||||
uint64_t ifi_ibytes;
|
||||
uint64_t ifi_obytes;
|
||||
uint64_t ifi_imcasts;
|
||||
uint64_t ifi_omcasts;
|
||||
uint64_t ifi_iqdrops;
|
||||
uint64_t ifi_oqdrops;
|
||||
uint64_t ifi_noproto;
|
||||
uint64_t ifi_hwassist;
|
||||
union {
|
||||
time_t tt;
|
||||
uint64_t ph;
|
||||
} __ifi_epoch;
|
||||
union {
|
||||
struct timeval tv;
|
||||
struct {
|
||||
uint64_t ph1;
|
||||
uint64_t ph2;
|
||||
} ph;
|
||||
} __ifi_lastchange;
|
||||
};
|
||||
|
||||
struct if_msghdr_freebsd7 {
|
||||
u_short ifm_msglen;
|
||||
u_char ifm_version;
|
||||
u_char ifm_type;
|
||||
int ifm_addrs;
|
||||
int ifm_flags;
|
||||
u_short ifm_index;
|
||||
struct if_data_freebsd7 ifm_data;
|
||||
};
|
||||
|
||||
struct if_msghdr_freebsd8 {
|
||||
u_short ifm_msglen;
|
||||
u_char ifm_version;
|
||||
u_char ifm_type;
|
||||
int ifm_addrs;
|
||||
int ifm_flags;
|
||||
u_short ifm_index;
|
||||
struct if_data_freebsd8 ifm_data;
|
||||
};
|
||||
|
||||
struct if_msghdr_freebsd9 {
|
||||
u_short ifm_msglen;
|
||||
u_char ifm_version;
|
||||
u_char ifm_type;
|
||||
int ifm_addrs;
|
||||
int ifm_flags;
|
||||
u_short ifm_index;
|
||||
struct if_data_freebsd9 ifm_data;
|
||||
};
|
||||
|
||||
struct if_msghdr_freebsd10 {
|
||||
u_short ifm_msglen;
|
||||
u_char ifm_version;
|
||||
u_char ifm_type;
|
||||
int ifm_addrs;
|
||||
int ifm_flags;
|
||||
u_short ifm_index;
|
||||
struct if_data_freebsd10 ifm_data;
|
||||
};
|
||||
|
||||
struct if_msghdr_freebsd11 {
|
||||
u_short ifm_msglen;
|
||||
u_char ifm_version;
|
||||
u_char ifm_type;
|
||||
int ifm_addrs;
|
||||
int ifm_flags;
|
||||
u_short ifm_index;
|
||||
struct if_data_freebsd11 ifm_data;
|
||||
};
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = C.AF_UNSPEC
|
||||
sysAF_INET = C.AF_INET
|
||||
sysAF_ROUTE = C.AF_ROUTE
|
||||
sysAF_LINK = C.AF_LINK
|
||||
sysAF_INET6 = C.AF_INET6
|
||||
|
||||
sysNET_RT_DUMP = C.NET_RT_DUMP
|
||||
sysNET_RT_FLAGS = C.NET_RT_FLAGS
|
||||
sysNET_RT_IFLIST = C.NET_RT_IFLIST
|
||||
sysNET_RT_IFMALIST = C.NET_RT_IFMALIST
|
||||
sysNET_RT_IFLISTL = C.NET_RT_IFLISTL
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = C.CTL_MAXNAME
|
||||
|
||||
sysCTL_UNSPEC = C.CTL_UNSPEC
|
||||
sysCTL_KERN = C.CTL_KERN
|
||||
sysCTL_VM = C.CTL_VM
|
||||
sysCTL_VFS = C.CTL_VFS
|
||||
sysCTL_NET = C.CTL_NET
|
||||
sysCTL_DEBUG = C.CTL_DEBUG
|
||||
sysCTL_HW = C.CTL_HW
|
||||
sysCTL_MACHDEP = C.CTL_MACHDEP
|
||||
sysCTL_USER = C.CTL_USER
|
||||
sysCTL_P1003_1B = C.CTL_P1003_1B
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = C.RTM_VERSION
|
||||
|
||||
sysRTM_ADD = C.RTM_ADD
|
||||
sysRTM_DELETE = C.RTM_DELETE
|
||||
sysRTM_CHANGE = C.RTM_CHANGE
|
||||
sysRTM_GET = C.RTM_GET
|
||||
sysRTM_LOSING = C.RTM_LOSING
|
||||
sysRTM_REDIRECT = C.RTM_REDIRECT
|
||||
sysRTM_MISS = C.RTM_MISS
|
||||
sysRTM_LOCK = C.RTM_LOCK
|
||||
sysRTM_RESOLVE = C.RTM_RESOLVE
|
||||
sysRTM_NEWADDR = C.RTM_NEWADDR
|
||||
sysRTM_DELADDR = C.RTM_DELADDR
|
||||
sysRTM_IFINFO = C.RTM_IFINFO
|
||||
sysRTM_NEWMADDR = C.RTM_NEWMADDR
|
||||
sysRTM_DELMADDR = C.RTM_DELMADDR
|
||||
sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE
|
||||
sysRTM_IEEE80211 = C.RTM_IEEE80211
|
||||
|
||||
sysRTA_DST = C.RTA_DST
|
||||
sysRTA_GATEWAY = C.RTA_GATEWAY
|
||||
sysRTA_NETMASK = C.RTA_NETMASK
|
||||
sysRTA_GENMASK = C.RTA_GENMASK
|
||||
sysRTA_IFP = C.RTA_IFP
|
||||
sysRTA_IFA = C.RTA_IFA
|
||||
sysRTA_AUTHOR = C.RTA_AUTHOR
|
||||
sysRTA_BRD = C.RTA_BRD
|
||||
|
||||
sysRTAX_DST = C.RTAX_DST
|
||||
sysRTAX_GATEWAY = C.RTAX_GATEWAY
|
||||
sysRTAX_NETMASK = C.RTAX_NETMASK
|
||||
sysRTAX_GENMASK = C.RTAX_GENMASK
|
||||
sysRTAX_IFP = C.RTAX_IFP
|
||||
sysRTAX_IFA = C.RTAX_IFA
|
||||
sysRTAX_AUTHOR = C.RTAX_AUTHOR
|
||||
sysRTAX_BRD = C.RTAX_BRD
|
||||
sysRTAX_MAX = C.RTAX_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = C.sizeof_struct_if_msghdrl
|
||||
sizeofIfaMsghdrFreeBSD10 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfaMsghdrlFreeBSD10 = C.sizeof_struct_ifa_msghdrl
|
||||
sizeofIfmaMsghdrFreeBSD10 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsFreeBSD10 = C.sizeof_struct_rt_metrics
|
||||
|
||||
sizeofIfMsghdrFreeBSD7 = C.sizeof_struct_if_msghdr_freebsd7
|
||||
sizeofIfMsghdrFreeBSD8 = C.sizeof_struct_if_msghdr_freebsd8
|
||||
sizeofIfMsghdrFreeBSD9 = C.sizeof_struct_if_msghdr_freebsd9
|
||||
sizeofIfMsghdrFreeBSD10 = C.sizeof_struct_if_msghdr_freebsd10
|
||||
sizeofIfMsghdrFreeBSD11 = C.sizeof_struct_if_msghdr_freebsd11
|
||||
|
||||
sizeofIfDataFreeBSD7 = C.sizeof_struct_if_data_freebsd7
|
||||
sizeofIfDataFreeBSD8 = C.sizeof_struct_if_data_freebsd8
|
||||
sizeofIfDataFreeBSD9 = C.sizeof_struct_if_data_freebsd9
|
||||
sizeofIfDataFreeBSD10 = C.sizeof_struct_if_data_freebsd10
|
||||
sizeofIfDataFreeBSD11 = C.sizeof_struct_if_data_freebsd11
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = C.sizeof_struct_if_msghdrl
|
||||
sizeofIfaMsghdrFreeBSD10Emu = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = C.sizeof_struct_ifa_msghdrl
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsFreeBSD10Emu = C.sizeof_struct_rt_metrics
|
||||
|
||||
sizeofIfMsghdrFreeBSD7Emu = C.sizeof_struct_if_msghdr_freebsd7
|
||||
sizeofIfMsghdrFreeBSD8Emu = C.sizeof_struct_if_msghdr_freebsd8
|
||||
sizeofIfMsghdrFreeBSD9Emu = C.sizeof_struct_if_msghdr_freebsd9
|
||||
sizeofIfMsghdrFreeBSD10Emu = C.sizeof_struct_if_msghdr_freebsd10
|
||||
sizeofIfMsghdrFreeBSD11Emu = C.sizeof_struct_if_msghdr_freebsd11
|
||||
|
||||
sizeofIfDataFreeBSD7Emu = C.sizeof_struct_if_data_freebsd7
|
||||
sizeofIfDataFreeBSD8Emu = C.sizeof_struct_if_data_freebsd8
|
||||
sizeofIfDataFreeBSD9Emu = C.sizeof_struct_if_data_freebsd9
|
||||
sizeofIfDataFreeBSD10Emu = C.sizeof_struct_if_data_freebsd10
|
||||
sizeofIfDataFreeBSD11Emu = C.sizeof_struct_if_data_freebsd11
|
||||
)
|
104
vendor/golang.org/x/net/route/defs_netbsd.go
generated
vendored
Normal file
104
vendor/golang.org/x/net/route/defs_netbsd.go
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = C.AF_UNSPEC
|
||||
sysAF_INET = C.AF_INET
|
||||
sysAF_ROUTE = C.AF_ROUTE
|
||||
sysAF_LINK = C.AF_LINK
|
||||
sysAF_INET6 = C.AF_INET6
|
||||
|
||||
sysNET_RT_DUMP = C.NET_RT_DUMP
|
||||
sysNET_RT_FLAGS = C.NET_RT_FLAGS
|
||||
sysNET_RT_IFLIST = C.NET_RT_IFLIST
|
||||
sysNET_RT_MAXID = C.NET_RT_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = C.CTL_MAXNAME
|
||||
|
||||
sysCTL_UNSPEC = C.CTL_UNSPEC
|
||||
sysCTL_KERN = C.CTL_KERN
|
||||
sysCTL_VM = C.CTL_VM
|
||||
sysCTL_VFS = C.CTL_VFS
|
||||
sysCTL_NET = C.CTL_NET
|
||||
sysCTL_DEBUG = C.CTL_DEBUG
|
||||
sysCTL_HW = C.CTL_HW
|
||||
sysCTL_MACHDEP = C.CTL_MACHDEP
|
||||
sysCTL_USER = C.CTL_USER
|
||||
sysCTL_DDB = C.CTL_DDB
|
||||
sysCTL_PROC = C.CTL_PROC
|
||||
sysCTL_VENDOR = C.CTL_VENDOR
|
||||
sysCTL_EMUL = C.CTL_EMUL
|
||||
sysCTL_SECURITY = C.CTL_SECURITY
|
||||
sysCTL_MAXID = C.CTL_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = C.RTM_VERSION
|
||||
|
||||
sysRTM_ADD = C.RTM_ADD
|
||||
sysRTM_DELETE = C.RTM_DELETE
|
||||
sysRTM_CHANGE = C.RTM_CHANGE
|
||||
sysRTM_GET = C.RTM_GET
|
||||
sysRTM_LOSING = C.RTM_LOSING
|
||||
sysRTM_REDIRECT = C.RTM_REDIRECT
|
||||
sysRTM_MISS = C.RTM_MISS
|
||||
sysRTM_LOCK = C.RTM_LOCK
|
||||
sysRTM_OLDADD = C.RTM_OLDADD
|
||||
sysRTM_OLDDEL = C.RTM_OLDDEL
|
||||
sysRTM_RESOLVE = C.RTM_RESOLVE
|
||||
sysRTM_NEWADDR = C.RTM_NEWADDR
|
||||
sysRTM_DELADDR = C.RTM_DELADDR
|
||||
sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE
|
||||
sysRTM_IEEE80211 = C.RTM_IEEE80211
|
||||
sysRTM_SETGATE = C.RTM_SETGATE
|
||||
sysRTM_LLINFO_UPD = C.RTM_LLINFO_UPD
|
||||
sysRTM_IFINFO = C.RTM_IFINFO
|
||||
sysRTM_CHGADDR = C.RTM_CHGADDR
|
||||
|
||||
sysRTA_DST = C.RTA_DST
|
||||
sysRTA_GATEWAY = C.RTA_GATEWAY
|
||||
sysRTA_NETMASK = C.RTA_NETMASK
|
||||
sysRTA_GENMASK = C.RTA_GENMASK
|
||||
sysRTA_IFP = C.RTA_IFP
|
||||
sysRTA_IFA = C.RTA_IFA
|
||||
sysRTA_AUTHOR = C.RTA_AUTHOR
|
||||
sysRTA_BRD = C.RTA_BRD
|
||||
sysRTA_TAG = C.RTA_TAG
|
||||
|
||||
sysRTAX_DST = C.RTAX_DST
|
||||
sysRTAX_GATEWAY = C.RTAX_GATEWAY
|
||||
sysRTAX_NETMASK = C.RTAX_NETMASK
|
||||
sysRTAX_GENMASK = C.RTAX_GENMASK
|
||||
sysRTAX_IFP = C.RTAX_IFP
|
||||
sysRTAX_IFA = C.RTAX_IFA
|
||||
sysRTAX_AUTHOR = C.RTAX_AUTHOR
|
||||
sysRTAX_BRD = C.RTAX_BRD
|
||||
sysRTAX_TAG = C.RTAX_TAG
|
||||
sysRTAX_MAX = C.RTAX_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrNetBSD7 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrNetBSD7 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfAnnouncemsghdrNetBSD7 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrNetBSD7 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsNetBSD7 = C.sizeof_struct_rt_metrics
|
||||
)
|
93
vendor/golang.org/x/net/route/defs_openbsd.go
generated
vendored
Normal file
93
vendor/golang.org/x/net/route/defs_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = C.AF_UNSPEC
|
||||
sysAF_INET = C.AF_INET
|
||||
sysAF_ROUTE = C.AF_ROUTE
|
||||
sysAF_LINK = C.AF_LINK
|
||||
sysAF_INET6 = C.AF_INET6
|
||||
|
||||
sysNET_RT_DUMP = C.NET_RT_DUMP
|
||||
sysNET_RT_FLAGS = C.NET_RT_FLAGS
|
||||
sysNET_RT_IFLIST = C.NET_RT_IFLIST
|
||||
sysNET_RT_STATS = C.NET_RT_STATS
|
||||
sysNET_RT_TABLE = C.NET_RT_TABLE
|
||||
sysNET_RT_IFNAMES = C.NET_RT_IFNAMES
|
||||
sysNET_RT_MAXID = C.NET_RT_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = C.CTL_MAXNAME
|
||||
|
||||
sysCTL_UNSPEC = C.CTL_UNSPEC
|
||||
sysCTL_KERN = C.CTL_KERN
|
||||
sysCTL_VM = C.CTL_VM
|
||||
sysCTL_FS = C.CTL_FS
|
||||
sysCTL_NET = C.CTL_NET
|
||||
sysCTL_DEBUG = C.CTL_DEBUG
|
||||
sysCTL_HW = C.CTL_HW
|
||||
sysCTL_MACHDEP = C.CTL_MACHDEP
|
||||
sysCTL_DDB = C.CTL_DDB
|
||||
sysCTL_VFS = C.CTL_VFS
|
||||
sysCTL_MAXID = C.CTL_MAXID
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = C.RTM_VERSION
|
||||
|
||||
sysRTM_ADD = C.RTM_ADD
|
||||
sysRTM_DELETE = C.RTM_DELETE
|
||||
sysRTM_CHANGE = C.RTM_CHANGE
|
||||
sysRTM_GET = C.RTM_GET
|
||||
sysRTM_LOSING = C.RTM_LOSING
|
||||
sysRTM_REDIRECT = C.RTM_REDIRECT
|
||||
sysRTM_MISS = C.RTM_MISS
|
||||
sysRTM_LOCK = C.RTM_LOCK
|
||||
sysRTM_RESOLVE = C.RTM_RESOLVE
|
||||
sysRTM_NEWADDR = C.RTM_NEWADDR
|
||||
sysRTM_DELADDR = C.RTM_DELADDR
|
||||
sysRTM_IFINFO = C.RTM_IFINFO
|
||||
sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE
|
||||
sysRTM_DESYNC = C.RTM_DESYNC
|
||||
|
||||
sysRTA_DST = C.RTA_DST
|
||||
sysRTA_GATEWAY = C.RTA_GATEWAY
|
||||
sysRTA_NETMASK = C.RTA_NETMASK
|
||||
sysRTA_GENMASK = C.RTA_GENMASK
|
||||
sysRTA_IFP = C.RTA_IFP
|
||||
sysRTA_IFA = C.RTA_IFA
|
||||
sysRTA_AUTHOR = C.RTA_AUTHOR
|
||||
sysRTA_BRD = C.RTA_BRD
|
||||
sysRTA_SRC = C.RTA_SRC
|
||||
sysRTA_SRCMASK = C.RTA_SRCMASK
|
||||
sysRTA_LABEL = C.RTA_LABEL
|
||||
|
||||
sysRTAX_DST = C.RTAX_DST
|
||||
sysRTAX_GATEWAY = C.RTAX_GATEWAY
|
||||
sysRTAX_NETMASK = C.RTAX_NETMASK
|
||||
sysRTAX_GENMASK = C.RTAX_GENMASK
|
||||
sysRTAX_IFP = C.RTAX_IFP
|
||||
sysRTAX_IFA = C.RTAX_IFA
|
||||
sysRTAX_AUTHOR = C.RTAX_AUTHOR
|
||||
sysRTAX_BRD = C.RTAX_BRD
|
||||
sysRTAX_SRC = C.RTAX_SRC
|
||||
sysRTAX_SRCMASK = C.RTAX_SRCMASK
|
||||
sysRTAX_LABEL = C.RTAX_LABEL
|
||||
sysRTAX_MAX = C.RTAX_MAX
|
||||
)
|
64
vendor/golang.org/x/net/route/interface.go
generated
vendored
Normal file
64
vendor/golang.org/x/net/route/interface.go
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
// An InterfaceMessage represents an interface message.
|
||||
type InterfaceMessage struct {
|
||||
Version int // message version
|
||||
Type int // message type
|
||||
Flags int // interface flags
|
||||
Index int // interface index
|
||||
Name string // interface name
|
||||
Addrs []Addr // addresses
|
||||
|
||||
extOff int // offset of header extension
|
||||
raw []byte // raw message
|
||||
}
|
||||
|
||||
// An InterfaceAddrMessage represents an interface address message.
|
||||
type InterfaceAddrMessage struct {
|
||||
Version int // message version
|
||||
Type int // message type
|
||||
Flags int // interface flags
|
||||
Index int // interface index
|
||||
Addrs []Addr // addresses
|
||||
|
||||
raw []byte // raw message
|
||||
}
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceAddrMessage) Sys() []Sys { return nil }
|
||||
|
||||
// An InterfaceMulticastAddrMessage represents an interface multicast
|
||||
// address message.
|
||||
type InterfaceMulticastAddrMessage struct {
|
||||
Version int // message version
|
||||
Type int // messsage type
|
||||
Flags int // interface flags
|
||||
Index int // interface index
|
||||
Addrs []Addr // addresses
|
||||
|
||||
raw []byte // raw message
|
||||
}
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMulticastAddrMessage) Sys() []Sys { return nil }
|
||||
|
||||
// An InterfaceAnnounceMessage represents an interface announcement
|
||||
// message.
|
||||
type InterfaceAnnounceMessage struct {
|
||||
Version int // message version
|
||||
Type int // message type
|
||||
Index int // interface index
|
||||
Name string // interface name
|
||||
What int // what type of announcement
|
||||
|
||||
raw []byte // raw message
|
||||
}
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceAnnounceMessage) Sys() []Sys { return nil }
|
32
vendor/golang.org/x/net/route/interface_announce.go
generated
vendored
Normal file
32
vendor/golang.org/x/net/route/interface_announce.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2016 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 dragonfly freebsd netbsd
|
||||
|
||||
package route
|
||||
|
||||
func (w *wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &InterfaceAnnounceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Index: int(nativeEndian.Uint16(b[4:6])),
|
||||
What: int(nativeEndian.Uint16(b[22:24])),
|
||||
raw: b[:l],
|
||||
}
|
||||
for i := 0; i < 16; i++ {
|
||||
if b[6+i] != 0 {
|
||||
continue
|
||||
}
|
||||
m.Name = string(b[6 : 6+i])
|
||||
break
|
||||
}
|
||||
return m, nil
|
||||
}
|
66
vendor/golang.org/x/net/route/interface_classic.go
generated
vendored
Normal file
66
vendor/golang.org/x/net/route/interface_classic.go
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly netbsd
|
||||
|
||||
package route
|
||||
|
||||
import "runtime"
|
||||
|
||||
func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[4:8]))
|
||||
if attrs&sysRTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Addrs: make([]Addr, sysRTAX_MAX),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
extOff: w.extOff,
|
||||
raw: b[:l],
|
||||
}
|
||||
a, err := parseLinkAddr(b[w.bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[sysRTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (w *wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &InterfaceAddrMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
raw: b[:l],
|
||||
}
|
||||
if runtime.GOOS == "netbsd" {
|
||||
m.Index = int(nativeEndian.Uint16(b[16:18]))
|
||||
} else {
|
||||
m.Index = int(nativeEndian.Uint16(b[12:14]))
|
||||
}
|
||||
var err error
|
||||
m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
78
vendor/golang.org/x/net/route/interface_freebsd.go
generated
vendored
Normal file
78
vendor/golang.org/x/net/route/interface_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, error) {
|
||||
var extOff, bodyOff int
|
||||
if typ == sysNET_RT_IFLISTL {
|
||||
if len(b) < 20 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
extOff = int(nativeEndian.Uint16(b[18:20]))
|
||||
bodyOff = int(nativeEndian.Uint16(b[16:18]))
|
||||
} else {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
extOff = w.extOff
|
||||
bodyOff = w.bodyOff
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[4:8]))
|
||||
if attrs&sysRTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
Addrs: make([]Addr, sysRTAX_MAX),
|
||||
extOff: extOff,
|
||||
raw: b[:l],
|
||||
}
|
||||
a, err := parseLinkAddr(b[bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[sysRTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (w *wireFormat) parseInterfaceAddrMessage(typ RIBType, b []byte) (Message, error) {
|
||||
var bodyOff int
|
||||
if typ == sysNET_RT_IFLISTL {
|
||||
if len(b) < 24 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
bodyOff = int(nativeEndian.Uint16(b[16:18]))
|
||||
} else {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
bodyOff = w.bodyOff
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &InterfaceAddrMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
raw: b[:l],
|
||||
}
|
||||
var err error
|
||||
m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
30
vendor/golang.org/x/net/route/interface_multicast.go
generated
vendored
Normal file
30
vendor/golang.org/x/net/route/interface_multicast.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd
|
||||
|
||||
package route
|
||||
|
||||
func (w *wireFormat) parseInterfaceMulticastAddrMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &InterfaceMulticastAddrMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
raw: b[:l],
|
||||
}
|
||||
var err error
|
||||
m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
83
vendor/golang.org/x/net/route/interface_openbsd.go
generated
vendored
Normal file
83
vendor/golang.org/x/net/route/interface_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < 32 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[12:16]))
|
||||
if attrs&sysRTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[16:20])),
|
||||
Index: int(nativeEndian.Uint16(b[6:8])),
|
||||
Addrs: make([]Addr, sysRTAX_MAX),
|
||||
raw: b[:l],
|
||||
}
|
||||
a, err := parseLinkAddr(b[int(nativeEndian.Uint16(b[4:6])):])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[sysRTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (*wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < 24 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
bodyOff := int(nativeEndian.Uint16(b[4:6]))
|
||||
m := &InterfaceAddrMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[12:16])),
|
||||
Index: int(nativeEndian.Uint16(b[6:8])),
|
||||
raw: b[:l],
|
||||
}
|
||||
var err error
|
||||
m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (*wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < 26 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &InterfaceAnnounceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Index: int(nativeEndian.Uint16(b[6:8])),
|
||||
What: int(nativeEndian.Uint16(b[8:10])),
|
||||
raw: b[:l],
|
||||
}
|
||||
for i := 0; i < 16; i++ {
|
||||
if b[10+i] != 0 {
|
||||
continue
|
||||
}
|
||||
m.Name = string(b[10 : 10+i])
|
||||
break
|
||||
}
|
||||
return m, nil
|
||||
}
|
70
vendor/golang.org/x/net/route/message.go
generated
vendored
Normal file
70
vendor/golang.org/x/net/route/message.go
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
// A Message represents a routing message.
|
||||
//
|
||||
// Note: This interface will be changed to support Marshal method in
|
||||
// future version.
|
||||
type Message interface {
|
||||
// Sys returns operating system-specific information.
|
||||
Sys() []Sys
|
||||
}
|
||||
|
||||
// A Sys reprensents operating system-specific information.
|
||||
type Sys interface {
|
||||
// SysType returns a type of operating system-specific
|
||||
// information.
|
||||
SysType() SysType
|
||||
}
|
||||
|
||||
// A SysType represents a type of operating system-specific
|
||||
// information.
|
||||
type SysType int
|
||||
|
||||
const (
|
||||
SysMetrics SysType = iota
|
||||
SysStats
|
||||
)
|
||||
|
||||
// ParseRIB parses b as a routing information base and returns a list
|
||||
// of routing messages.
|
||||
func ParseRIB(typ RIBType, b []byte) ([]Message, error) {
|
||||
if !typ.parseable() {
|
||||
return nil, errUnsupportedMessage
|
||||
}
|
||||
var msgs []Message
|
||||
nmsgs, nskips := 0, 0
|
||||
for len(b) > 4 {
|
||||
nmsgs++
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if b[2] != sysRTM_VERSION {
|
||||
b = b[l:]
|
||||
continue
|
||||
}
|
||||
mtyp := int(b[3])
|
||||
if fn, ok := parseFns[mtyp]; !ok {
|
||||
nskips++
|
||||
} else {
|
||||
m, err := fn(typ, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if m == nil {
|
||||
nskips++
|
||||
} else {
|
||||
msgs = append(msgs, m)
|
||||
}
|
||||
}
|
||||
b = b[l:]
|
||||
}
|
||||
// We failed to parse any of the messages - version mismatch?
|
||||
if nmsgs != len(msgs)+nskips {
|
||||
return nil, errMessageMismatch
|
||||
}
|
||||
return msgs, nil
|
||||
}
|
74
vendor/golang.org/x/net/route/route.go
generated
vendored
Normal file
74
vendor/golang.org/x/net/route/route.go
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
// Package route provides basic functions for the manipulation of
|
||||
// packet routing facilities on BSD variants.
|
||||
//
|
||||
// The package supports any version of Darwin, any version of
|
||||
// DragonFly BSD, FreeBSD 7 through 11, NetBSD 6 and above, and
|
||||
// OpenBSD 5.6 and above.
|
||||
package route
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
errUnsupportedMessage = errors.New("unsupported message")
|
||||
errMessageMismatch = errors.New("message mismatch")
|
||||
errMessageTooShort = errors.New("message too short")
|
||||
errInvalidMessage = errors.New("invalid message")
|
||||
errInvalidAddr = errors.New("invalid address")
|
||||
)
|
||||
|
||||
// A RouteMessage represents a message conveying an address prefix, a
|
||||
// nexthop address and an output interface.
|
||||
type RouteMessage struct {
|
||||
Version int // message version
|
||||
Type int // message type
|
||||
Flags int // route flags
|
||||
Index int // interface index when atatched
|
||||
Addrs []Addr // addresses
|
||||
|
||||
extOff int // offset of header extension
|
||||
raw []byte // raw message
|
||||
}
|
||||
|
||||
// A RIBType reprensents a type of routing information base.
|
||||
type RIBType int
|
||||
|
||||
const (
|
||||
RIBTypeRoute RIBType = syscall.NET_RT_DUMP
|
||||
RIBTypeInterface RIBType = syscall.NET_RT_IFLIST
|
||||
)
|
||||
|
||||
// FetchRIB fetches a routing information base from the operating
|
||||
// system.
|
||||
//
|
||||
// The provided af must be an address family.
|
||||
//
|
||||
// The provided arg must be a RIBType-specific argument.
|
||||
// When RIBType is related to routes, arg might be a set of route
|
||||
// flags. When RIBType is related to network interfaces, arg might be
|
||||
// an interface index or a set of interface flags. In most cases, zero
|
||||
// means a wildcard.
|
||||
func FetchRIB(af int, typ RIBType, arg int) ([]byte, error) {
|
||||
mib := [6]int32{sysCTL_NET, sysAF_ROUTE, 0, int32(af), int32(typ), int32(arg)}
|
||||
n := uintptr(0)
|
||||
if err := sysctl(mib[:], nil, &n, nil, 0); err != nil {
|
||||
return nil, os.NewSyscallError("sysctl", err)
|
||||
}
|
||||
if n == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
b := make([]byte, n)
|
||||
if err := sysctl(mib[:], &b[0], &n, nil, 0); err != nil {
|
||||
return nil, os.NewSyscallError("sysctl", err)
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
31
vendor/golang.org/x/net/route/route_classic.go
generated
vendored
Normal file
31
vendor/golang.org/x/net/route/route_classic.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd
|
||||
|
||||
package route
|
||||
|
||||
func (w *wireFormat) parseRouteMessage(typ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < w.bodyOff {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &RouteMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[4:6])),
|
||||
extOff: w.extOff,
|
||||
raw: b[:l],
|
||||
}
|
||||
var err error
|
||||
m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[w.bodyOff:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
28
vendor/golang.org/x/net/route/route_openbsd.go
generated
vendored
Normal file
28
vendor/golang.org/x/net/route/route_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < 40 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
if len(b) < l {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
m := &RouteMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[16:20])),
|
||||
Index: int(nativeEndian.Uint16(b[6:8])),
|
||||
raw: b[:l],
|
||||
}
|
||||
as, err := parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[int(nativeEndian.Uint16(b[4:6])):])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs = as
|
||||
return m, nil
|
||||
}
|
40
vendor/golang.org/x/net/route/sys.go
generated
vendored
Normal file
40
vendor/golang.org/x/net/route/sys.go
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
import "unsafe"
|
||||
|
||||
var (
|
||||
nativeEndian binaryByteOrder
|
||||
kernelAlign int
|
||||
parseFns map[int]parseFn
|
||||
)
|
||||
|
||||
func init() {
|
||||
i := uint32(1)
|
||||
b := (*[4]byte)(unsafe.Pointer(&i))
|
||||
if b[0] == 1 {
|
||||
nativeEndian = littleEndian
|
||||
} else {
|
||||
nativeEndian = bigEndian
|
||||
}
|
||||
kernelAlign, parseFns = probeRoutingStack()
|
||||
}
|
||||
|
||||
func roundup(l int) int {
|
||||
if l == 0 {
|
||||
return kernelAlign
|
||||
}
|
||||
return (l + kernelAlign - 1) & ^(kernelAlign - 1)
|
||||
}
|
||||
|
||||
type parseFn func(RIBType, []byte) (Message, error)
|
||||
|
||||
type wireFormat struct {
|
||||
extOff int // offset of header extension
|
||||
bodyOff int // offset of message body
|
||||
}
|
80
vendor/golang.org/x/net/route/sys_darwin.go
generated
vendored
Normal file
80
vendor/golang.org/x/net/route/sys_darwin.go
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
func (typ RIBType) parseable() bool {
|
||||
switch typ {
|
||||
case sysNET_RT_STAT, sysNET_RT_TRASH:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// A RouteMetrics represents route metrics.
|
||||
type RouteMetrics struct {
|
||||
PathMTU int // path maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *RouteMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A InterfaceMetrics represents interface metrics.
|
||||
type InterfaceMetrics struct {
|
||||
Type int // interface type
|
||||
MTU int // maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&InterfaceMetrics{
|
||||
Type: int(m.raw[m.extOff]),
|
||||
MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]parseFn) {
|
||||
rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15}
|
||||
rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15}
|
||||
ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15}
|
||||
ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15}
|
||||
ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15}
|
||||
// Darwin kernels require 32-bit aligned access to routing facilities.
|
||||
return 4, map[int]parseFn{
|
||||
sysRTM_ADD: rtm.parseRouteMessage,
|
||||
sysRTM_DELETE: rtm.parseRouteMessage,
|
||||
sysRTM_CHANGE: rtm.parseRouteMessage,
|
||||
sysRTM_GET: rtm.parseRouteMessage,
|
||||
sysRTM_LOSING: rtm.parseRouteMessage,
|
||||
sysRTM_REDIRECT: rtm.parseRouteMessage,
|
||||
sysRTM_MISS: rtm.parseRouteMessage,
|
||||
sysRTM_LOCK: rtm.parseRouteMessage,
|
||||
sysRTM_RESOLVE: rtm.parseRouteMessage,
|
||||
sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_DELADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_IFINFO: ifm.parseInterfaceMessage,
|
||||
sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_IFINFO2: ifm2.parseInterfaceMessage,
|
||||
sysRTM_NEWMADDR2: ifmam2.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_GET2: rtm2.parseRouteMessage,
|
||||
}
|
||||
}
|
71
vendor/golang.org/x/net/route/sys_dragonfly.go
generated
vendored
Normal file
71
vendor/golang.org/x/net/route/sys_dragonfly.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
import "unsafe"
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
|
||||
// A RouteMetrics represents route metrics.
|
||||
type RouteMetrics struct {
|
||||
PathMTU int // path maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *RouteMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A InterfaceMetrics represents interface metrics.
|
||||
type InterfaceMetrics struct {
|
||||
Type int // interface type
|
||||
MTU int // maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&InterfaceMetrics{
|
||||
Type: int(m.raw[m.extOff]),
|
||||
MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]parseFn) {
|
||||
var p uintptr
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrDragonFlyBSD4}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDragonFlyBSD4}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrDragonFlyBSD4, bodyOff: sizeofIfaMsghdrDragonFlyBSD4}
|
||||
ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDragonFlyBSD4, bodyOff: sizeofIfmaMsghdrDragonFlyBSD4}
|
||||
ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrDragonFlyBSD4, bodyOff: sizeofIfAnnouncemsghdrDragonFlyBSD4}
|
||||
return int(unsafe.Sizeof(p)), map[int]parseFn{
|
||||
sysRTM_ADD: rtm.parseRouteMessage,
|
||||
sysRTM_DELETE: rtm.parseRouteMessage,
|
||||
sysRTM_CHANGE: rtm.parseRouteMessage,
|
||||
sysRTM_GET: rtm.parseRouteMessage,
|
||||
sysRTM_LOSING: rtm.parseRouteMessage,
|
||||
sysRTM_REDIRECT: rtm.parseRouteMessage,
|
||||
sysRTM_MISS: rtm.parseRouteMessage,
|
||||
sysRTM_LOCK: rtm.parseRouteMessage,
|
||||
sysRTM_RESOLVE: rtm.parseRouteMessage,
|
||||
sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_DELADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_IFINFO: ifm.parseInterfaceMessage,
|
||||
sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage,
|
||||
}
|
||||
}
|
150
vendor/golang.org/x/net/route/sys_freebsd.go
generated
vendored
Normal file
150
vendor/golang.org/x/net/route/sys_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
|
||||
// A RouteMetrics represents route metrics.
|
||||
type RouteMetrics struct {
|
||||
PathMTU int // path maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *RouteMessage) Sys() []Sys {
|
||||
if kernelAlign == 8 {
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])),
|
||||
},
|
||||
}
|
||||
}
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A InterfaceMetrics represents interface metrics.
|
||||
type InterfaceMetrics struct {
|
||||
Type int // interface type
|
||||
MTU int // maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&InterfaceMetrics{
|
||||
Type: int(m.raw[m.extOff]),
|
||||
MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]parseFn) {
|
||||
var p uintptr
|
||||
wordSize := int(unsafe.Sizeof(p))
|
||||
align := int(unsafe.Sizeof(p))
|
||||
// In the case of kern.supported_archs="amd64 i386", we need
|
||||
// to know the underlying kernel's architecture because the
|
||||
// alignment for routing facilities are set at the build time
|
||||
// of the kernel.
|
||||
conf, _ := syscall.Sysctl("kern.conftxt")
|
||||
for i, j := 0, 0; j < len(conf); j++ {
|
||||
if conf[j] != '\n' {
|
||||
continue
|
||||
}
|
||||
s := conf[i:j]
|
||||
i = j + 1
|
||||
if len(s) > len("machine") && s[:len("machine")] == "machine" {
|
||||
s = s[len("machine"):]
|
||||
for k := 0; k < len(s); k++ {
|
||||
if s[k] == ' ' || s[k] == '\t' {
|
||||
s = s[1:]
|
||||
}
|
||||
break
|
||||
}
|
||||
if s == "amd64" {
|
||||
align = 8
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
var rtm, ifm, ifam, ifmam, ifanm *wireFormat
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10Emu - sizeofRtMetricsFreeBSD10Emu, bodyOff: sizeofRtMsghdrFreeBSD10Emu}
|
||||
ifm = &wireFormat{extOff: 16}
|
||||
ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10Emu, bodyOff: sizeofIfaMsghdrFreeBSD10Emu}
|
||||
ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10Emu, bodyOff: sizeofIfmaMsghdrFreeBSD10Emu}
|
||||
ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10Emu, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10Emu}
|
||||
} else {
|
||||
rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10 - sizeofRtMetricsFreeBSD10, bodyOff: sizeofRtMsghdrFreeBSD10}
|
||||
ifm = &wireFormat{extOff: 16}
|
||||
ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10, bodyOff: sizeofIfaMsghdrFreeBSD10}
|
||||
ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10, bodyOff: sizeofIfmaMsghdrFreeBSD10}
|
||||
ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10}
|
||||
}
|
||||
rel, _ := syscall.SysctlUint32("kern.osreldate")
|
||||
switch {
|
||||
case rel < 800000:
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD7Emu
|
||||
} else {
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD7
|
||||
}
|
||||
case 800000 <= rel && rel < 900000:
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD8Emu
|
||||
} else {
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD8
|
||||
}
|
||||
case 900000 <= rel && rel < 1000000:
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD9Emu
|
||||
} else {
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD9
|
||||
}
|
||||
case 1000000 <= rel && rel < 1100000:
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD10Emu
|
||||
} else {
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD10
|
||||
}
|
||||
default:
|
||||
if align != wordSize { // 386 emulation on amd64
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD11Emu
|
||||
} else {
|
||||
ifm.bodyOff = sizeofIfMsghdrFreeBSD11
|
||||
}
|
||||
}
|
||||
return align, map[int]parseFn{
|
||||
sysRTM_ADD: rtm.parseRouteMessage,
|
||||
sysRTM_DELETE: rtm.parseRouteMessage,
|
||||
sysRTM_CHANGE: rtm.parseRouteMessage,
|
||||
sysRTM_GET: rtm.parseRouteMessage,
|
||||
sysRTM_LOSING: rtm.parseRouteMessage,
|
||||
sysRTM_REDIRECT: rtm.parseRouteMessage,
|
||||
sysRTM_MISS: rtm.parseRouteMessage,
|
||||
sysRTM_LOCK: rtm.parseRouteMessage,
|
||||
sysRTM_RESOLVE: rtm.parseRouteMessage,
|
||||
sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_DELADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_IFINFO: ifm.parseInterfaceMessage,
|
||||
sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage,
|
||||
sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage,
|
||||
}
|
||||
}
|
67
vendor/golang.org/x/net/route/sys_netbsd.go
generated
vendored
Normal file
67
vendor/golang.org/x/net/route/sys_netbsd.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
|
||||
// A RouteMetrics represents route metrics.
|
||||
type RouteMetrics struct {
|
||||
PathMTU int // path maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *RouteMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A InterfaceMetrics represents interface metrics.
|
||||
type InterfaceMetrics struct {
|
||||
Type int // interface type
|
||||
MTU int // maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&InterfaceMetrics{
|
||||
Type: int(m.raw[m.extOff]),
|
||||
MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]parseFn) {
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7}
|
||||
ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7}
|
||||
// NetBSD 6 and above kernels require 64-bit aligned access to
|
||||
// routing facilities.
|
||||
return 8, map[int]parseFn{
|
||||
sysRTM_ADD: rtm.parseRouteMessage,
|
||||
sysRTM_DELETE: rtm.parseRouteMessage,
|
||||
sysRTM_CHANGE: rtm.parseRouteMessage,
|
||||
sysRTM_GET: rtm.parseRouteMessage,
|
||||
sysRTM_LOSING: rtm.parseRouteMessage,
|
||||
sysRTM_REDIRECT: rtm.parseRouteMessage,
|
||||
sysRTM_MISS: rtm.parseRouteMessage,
|
||||
sysRTM_LOCK: rtm.parseRouteMessage,
|
||||
sysRTM_RESOLVE: rtm.parseRouteMessage,
|
||||
sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_DELADDR: ifam.parseInterfaceAddrMessage,
|
||||
sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage,
|
||||
sysRTM_IFINFO: ifm.parseInterfaceMessage,
|
||||
}
|
||||
}
|
72
vendor/golang.org/x/net/route/sys_openbsd.go
generated
vendored
Normal file
72
vendor/golang.org/x/net/route/sys_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2016 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 route
|
||||
|
||||
import "unsafe"
|
||||
|
||||
func (typ RIBType) parseable() bool {
|
||||
switch typ {
|
||||
case sysNET_RT_STATS, sysNET_RT_TABLE:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// A RouteMetrics represents route metrics.
|
||||
type RouteMetrics struct {
|
||||
PathMTU int // path maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *RouteMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&RouteMetrics{
|
||||
PathMTU: int(nativeEndian.Uint32(m.raw[60:64])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A InterfaceMetrics represents interface metrics.
|
||||
type InterfaceMetrics struct {
|
||||
Type int // interface type
|
||||
MTU int // maximum transmission unit
|
||||
}
|
||||
|
||||
// SysType implements the SysType method of Sys interface.
|
||||
func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
|
||||
|
||||
// Sys implements the Sys method of Message interface.
|
||||
func (m *InterfaceMessage) Sys() []Sys {
|
||||
return []Sys{
|
||||
&InterfaceMetrics{
|
||||
Type: int(m.raw[24]),
|
||||
MTU: int(nativeEndian.Uint32(m.raw[28:32])),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]parseFn) {
|
||||
var p uintptr
|
||||
nooff := &wireFormat{extOff: -1, bodyOff: -1}
|
||||
return int(unsafe.Sizeof(p)), map[int]parseFn{
|
||||
sysRTM_ADD: nooff.parseRouteMessage,
|
||||
sysRTM_DELETE: nooff.parseRouteMessage,
|
||||
sysRTM_CHANGE: nooff.parseRouteMessage,
|
||||
sysRTM_GET: nooff.parseRouteMessage,
|
||||
sysRTM_LOSING: nooff.parseRouteMessage,
|
||||
sysRTM_REDIRECT: nooff.parseRouteMessage,
|
||||
sysRTM_MISS: nooff.parseRouteMessage,
|
||||
sysRTM_LOCK: nooff.parseRouteMessage,
|
||||
sysRTM_RESOLVE: nooff.parseRouteMessage,
|
||||
sysRTM_NEWADDR: nooff.parseInterfaceAddrMessage,
|
||||
sysRTM_DELADDR: nooff.parseInterfaceAddrMessage,
|
||||
sysRTM_IFINFO: nooff.parseInterfaceMessage,
|
||||
sysRTM_IFANNOUNCE: nooff.parseInterfaceAnnounceMessage,
|
||||
}
|
||||
}
|
33
vendor/golang.org/x/net/route/syscall.go
generated
vendored
Normal file
33
vendor/golang.org/x/net/route/syscall.go
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// TODO: replace with runtime.KeepAlive when available
|
||||
//go:noescape
|
||||
func keepAlive(p unsafe.Pointer)
|
||||
|
||||
var zero uintptr
|
||||
|
||||
func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
|
||||
var p unsafe.Pointer
|
||||
if len(mib) > 0 {
|
||||
p = unsafe.Pointer(&mib[0])
|
||||
} else {
|
||||
p = unsafe.Pointer(&zero)
|
||||
}
|
||||
_, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
|
||||
keepAlive(p)
|
||||
if errno != 0 {
|
||||
return error(errno)
|
||||
}
|
||||
return nil
|
||||
}
|
8
vendor/golang.org/x/net/route/syscall.s
generated
vendored
Normal file
8
vendor/golang.org/x/net/route/syscall.s
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
TEXT ·keepAlive(SB),NOSPLIT,$0
|
||||
RET
|
93
vendor/golang.org/x/net/route/zsys_darwin.go
generated
vendored
Normal file
93
vendor/golang.org/x/net/route/zsys_darwin.go
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_darwin.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x1e
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_STAT = 0x4
|
||||
sysNET_RT_TRASH = 0x5
|
||||
sysNET_RT_IFLIST2 = 0x6
|
||||
sysNET_RT_DUMP2 = 0x7
|
||||
sysNET_RT_MAXID = 0xa
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0xc
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_MAXID = 0x9
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x5
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_OLDADD = 0x9
|
||||
sysRTM_OLDDEL = 0xa
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_NEWMADDR = 0xf
|
||||
sysRTM_DELMADDR = 0x10
|
||||
sysRTM_IFINFO2 = 0x12
|
||||
sysRTM_NEWMADDR2 = 0x13
|
||||
sysRTM_GET2 = 0x14
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_MAX = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDarwin15 = 0x70
|
||||
sizeofIfaMsghdrDarwin15 = 0x14
|
||||
sizeofIfmaMsghdrDarwin15 = 0x10
|
||||
sizeofIfMsghdr2Darwin15 = 0xa0
|
||||
sizeofIfmaMsghdr2Darwin15 = 0x14
|
||||
sizeofIfDataDarwin15 = 0x60
|
||||
sizeofIfData64Darwin15 = 0x80
|
||||
|
||||
sizeofRtMsghdrDarwin15 = 0x5c
|
||||
sizeofRtMsghdr2Darwin15 = 0x5c
|
||||
sizeofRtMetricsDarwin15 = 0x38
|
||||
)
|
92
vendor/golang.org/x/net/route/zsys_dragonfly.go
generated
vendored
Normal file
92
vendor/golang.org/x/net/route/zsys_dragonfly.go
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_dragonfly.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x1c
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_MAXID = 0x4
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0xc
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_P1003_1B = 0x9
|
||||
sysCTL_LWKT = 0xa
|
||||
sysCTL_MAXID = 0xb
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x6
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_OLDADD = 0x9
|
||||
sysRTM_OLDDEL = 0xa
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_NEWMADDR = 0xf
|
||||
sysRTM_DELMADDR = 0x10
|
||||
sysRTM_IFANNOUNCE = 0x11
|
||||
sysRTM_IEEE80211 = 0x12
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
sysRTA_MPLS1 = 0x100
|
||||
sysRTA_MPLS2 = 0x200
|
||||
sysRTA_MPLS3 = 0x400
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_MPLS1 = 0x8
|
||||
sysRTAX_MPLS2 = 0x9
|
||||
sysRTAX_MPLS3 = 0xa
|
||||
sysRTAX_MAX = 0xb
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDragonFlyBSD4 = 0xb0
|
||||
sizeofIfaMsghdrDragonFlyBSD4 = 0x14
|
||||
sizeofIfmaMsghdrDragonFlyBSD4 = 0x10
|
||||
sizeofIfAnnouncemsghdrDragonFlyBSD4 = 0x18
|
||||
|
||||
sizeofRtMsghdrDragonFlyBSD4 = 0x98
|
||||
sizeofRtMetricsDragonFlyBSD4 = 0x70
|
||||
)
|
120
vendor/golang.org/x/net/route/zsys_freebsd_386.go
generated
vendored
Normal file
120
vendor/golang.org/x/net/route/zsys_freebsd_386.go
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_freebsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x1c
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_IFMALIST = 0x4
|
||||
sysNET_RT_IFLISTL = 0x5
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0x18
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_P1003_1B = 0x9
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x5
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_NEWMADDR = 0xf
|
||||
sysRTM_DELMADDR = 0x10
|
||||
sysRTM_IFANNOUNCE = 0x11
|
||||
sysRTM_IEEE80211 = 0x12
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_MAX = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x5c
|
||||
sizeofRtMetricsFreeBSD10 = 0x38
|
||||
|
||||
sizeofIfMsghdrFreeBSD7 = 0x60
|
||||
sizeofIfMsghdrFreeBSD8 = 0x60
|
||||
sizeofIfMsghdrFreeBSD9 = 0x60
|
||||
sizeofIfMsghdrFreeBSD10 = 0x64
|
||||
sizeofIfMsghdrFreeBSD11 = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7 = 0x50
|
||||
sizeofIfDataFreeBSD8 = 0x50
|
||||
sizeofIfDataFreeBSD9 = 0x50
|
||||
sizeofIfDataFreeBSD10 = 0x54
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
// MODIFIED BY HAND FOR 386 EMULATION ON AMD64
|
||||
// 386 EMULATION USES THE UNDERLYING RAW DATA LAYOUT
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
sizeofIfMsghdrFreeBSD7Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD8Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD9Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD10Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD11Emu = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7Emu = 0x98
|
||||
sizeofIfDataFreeBSD8Emu = 0x98
|
||||
sizeofIfDataFreeBSD9Emu = 0x98
|
||||
sizeofIfDataFreeBSD10Emu = 0x98
|
||||
sizeofIfDataFreeBSD11Emu = 0x98
|
||||
)
|
117
vendor/golang.org/x/net/route/zsys_freebsd_amd64.go
generated
vendored
Normal file
117
vendor/golang.org/x/net/route/zsys_freebsd_amd64.go
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_freebsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x1c
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_IFMALIST = 0x4
|
||||
sysNET_RT_IFLISTL = 0x5
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0x18
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_P1003_1B = 0x9
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x5
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_NEWMADDR = 0xf
|
||||
sysRTM_DELMADDR = 0x10
|
||||
sysRTM_IFANNOUNCE = 0x11
|
||||
sysRTM_IEEE80211 = 0x12
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_MAX = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x98
|
||||
sizeofRtMetricsFreeBSD10 = 0x70
|
||||
|
||||
sizeofIfMsghdrFreeBSD7 = 0xa8
|
||||
sizeofIfMsghdrFreeBSD8 = 0xa8
|
||||
sizeofIfMsghdrFreeBSD9 = 0xa8
|
||||
sizeofIfMsghdrFreeBSD10 = 0xa8
|
||||
sizeofIfMsghdrFreeBSD11 = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7 = 0x98
|
||||
sizeofIfDataFreeBSD8 = 0x98
|
||||
sizeofIfDataFreeBSD9 = 0x98
|
||||
sizeofIfDataFreeBSD10 = 0x98
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
sizeofIfMsghdrFreeBSD7Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD8Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD9Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD10Emu = 0xa8
|
||||
sizeofIfMsghdrFreeBSD11Emu = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7Emu = 0x98
|
||||
sizeofIfDataFreeBSD8Emu = 0x98
|
||||
sizeofIfDataFreeBSD9Emu = 0x98
|
||||
sizeofIfDataFreeBSD10Emu = 0x98
|
||||
sizeofIfDataFreeBSD11Emu = 0x98
|
||||
)
|
117
vendor/golang.org/x/net/route/zsys_freebsd_arm.go
generated
vendored
Normal file
117
vendor/golang.org/x/net/route/zsys_freebsd_arm.go
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_freebsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x1c
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_IFMALIST = 0x4
|
||||
sysNET_RT_IFLISTL = 0x5
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0x18
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_P1003_1B = 0x9
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x5
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_NEWMADDR = 0xf
|
||||
sysRTM_DELMADDR = 0x10
|
||||
sysRTM_IFANNOUNCE = 0x11
|
||||
sysRTM_IEEE80211 = 0x12
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_MAX = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x5c
|
||||
sizeofRtMetricsFreeBSD10 = 0x38
|
||||
|
||||
sizeofIfMsghdrFreeBSD7 = 0x70
|
||||
sizeofIfMsghdrFreeBSD8 = 0x70
|
||||
sizeofIfMsghdrFreeBSD9 = 0x70
|
||||
sizeofIfMsghdrFreeBSD10 = 0x70
|
||||
sizeofIfMsghdrFreeBSD11 = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7 = 0x60
|
||||
sizeofIfDataFreeBSD8 = 0x60
|
||||
sizeofIfDataFreeBSD9 = 0x60
|
||||
sizeofIfDataFreeBSD10 = 0x60
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x5c
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x38
|
||||
|
||||
sizeofIfMsghdrFreeBSD7Emu = 0x70
|
||||
sizeofIfMsghdrFreeBSD8Emu = 0x70
|
||||
sizeofIfMsghdrFreeBSD9Emu = 0x70
|
||||
sizeofIfMsghdrFreeBSD10Emu = 0x70
|
||||
sizeofIfMsghdrFreeBSD11Emu = 0xa8
|
||||
|
||||
sizeofIfDataFreeBSD7Emu = 0x60
|
||||
sizeofIfDataFreeBSD8Emu = 0x60
|
||||
sizeofIfDataFreeBSD9Emu = 0x60
|
||||
sizeofIfDataFreeBSD10Emu = 0x60
|
||||
sizeofIfDataFreeBSD11Emu = 0x98
|
||||
)
|
91
vendor/golang.org/x/net/route/zsys_netbsd.go
generated
vendored
Normal file
91
vendor/golang.org/x/net/route/zsys_netbsd.go
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_netbsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x22
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x18
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x5
|
||||
sysNET_RT_MAXID = 0x6
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0xc
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_VFS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_USER = 0x8
|
||||
sysCTL_DDB = 0x9
|
||||
sysCTL_PROC = 0xa
|
||||
sysCTL_VENDOR = 0xb
|
||||
sysCTL_EMUL = 0xc
|
||||
sysCTL_SECURITY = 0xd
|
||||
sysCTL_MAXID = 0xe
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x4
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_OLDADD = 0x9
|
||||
sysRTM_OLDDEL = 0xa
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFANNOUNCE = 0x10
|
||||
sysRTM_IEEE80211 = 0x11
|
||||
sysRTM_SETGATE = 0x12
|
||||
sysRTM_LLINFO_UPD = 0x13
|
||||
sysRTM_IFINFO = 0x14
|
||||
sysRTM_CHGADDR = 0x15
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
sysRTA_TAG = 0x100
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_TAG = 0x8
|
||||
sysRTAX_MAX = 0x9
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrNetBSD7 = 0x98
|
||||
sizeofIfaMsghdrNetBSD7 = 0x18
|
||||
sizeofIfAnnouncemsghdrNetBSD7 = 0x18
|
||||
|
||||
sizeofRtMsghdrNetBSD7 = 0x78
|
||||
sizeofRtMetricsNetBSD7 = 0x50
|
||||
)
|
80
vendor/golang.org/x/net/route/zsys_openbsd.go
generated
vendored
Normal file
80
vendor/golang.org/x/net/route/zsys_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs defs_openbsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sysAF_UNSPEC = 0x0
|
||||
sysAF_INET = 0x2
|
||||
sysAF_ROUTE = 0x11
|
||||
sysAF_LINK = 0x12
|
||||
sysAF_INET6 = 0x18
|
||||
|
||||
sysNET_RT_DUMP = 0x1
|
||||
sysNET_RT_FLAGS = 0x2
|
||||
sysNET_RT_IFLIST = 0x3
|
||||
sysNET_RT_STATS = 0x4
|
||||
sysNET_RT_TABLE = 0x5
|
||||
sysNET_RT_IFNAMES = 0x6
|
||||
sysNET_RT_MAXID = 0x7
|
||||
)
|
||||
|
||||
const (
|
||||
sysCTL_MAXNAME = 0xc
|
||||
|
||||
sysCTL_UNSPEC = 0x0
|
||||
sysCTL_KERN = 0x1
|
||||
sysCTL_VM = 0x2
|
||||
sysCTL_FS = 0x3
|
||||
sysCTL_NET = 0x4
|
||||
sysCTL_DEBUG = 0x5
|
||||
sysCTL_HW = 0x6
|
||||
sysCTL_MACHDEP = 0x7
|
||||
sysCTL_DDB = 0x9
|
||||
sysCTL_VFS = 0xa
|
||||
sysCTL_MAXID = 0xb
|
||||
)
|
||||
|
||||
const (
|
||||
sysRTM_VERSION = 0x5
|
||||
|
||||
sysRTM_ADD = 0x1
|
||||
sysRTM_DELETE = 0x2
|
||||
sysRTM_CHANGE = 0x3
|
||||
sysRTM_GET = 0x4
|
||||
sysRTM_LOSING = 0x5
|
||||
sysRTM_REDIRECT = 0x6
|
||||
sysRTM_MISS = 0x7
|
||||
sysRTM_LOCK = 0x8
|
||||
sysRTM_RESOLVE = 0xb
|
||||
sysRTM_NEWADDR = 0xc
|
||||
sysRTM_DELADDR = 0xd
|
||||
sysRTM_IFINFO = 0xe
|
||||
sysRTM_IFANNOUNCE = 0xf
|
||||
sysRTM_DESYNC = 0x10
|
||||
|
||||
sysRTA_DST = 0x1
|
||||
sysRTA_GATEWAY = 0x2
|
||||
sysRTA_NETMASK = 0x4
|
||||
sysRTA_GENMASK = 0x8
|
||||
sysRTA_IFP = 0x10
|
||||
sysRTA_IFA = 0x20
|
||||
sysRTA_AUTHOR = 0x40
|
||||
sysRTA_BRD = 0x80
|
||||
sysRTA_SRC = 0x100
|
||||
sysRTA_SRCMASK = 0x200
|
||||
sysRTA_LABEL = 0x400
|
||||
|
||||
sysRTAX_DST = 0x0
|
||||
sysRTAX_GATEWAY = 0x1
|
||||
sysRTAX_NETMASK = 0x2
|
||||
sysRTAX_GENMASK = 0x3
|
||||
sysRTAX_IFP = 0x4
|
||||
sysRTAX_IFA = 0x5
|
||||
sysRTAX_AUTHOR = 0x6
|
||||
sysRTAX_BRD = 0x7
|
||||
sysRTAX_SRC = 0x8
|
||||
sysRTAX_SRCMASK = 0x9
|
||||
sysRTAX_LABEL = 0xa
|
||||
sysRTAX_MAX = 0xb
|
||||
)
|
27
vendor/golang.org/x/sys/unix/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/sys/unix/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
vendor/golang.org/x/sys/unix/asm.s
generated
vendored
Normal file
10
vendor/golang.org/x/sys/unix/asm.s
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright 2014 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"
|
||||
|
||||
TEXT ·use(SB),NOSPLIT,$0
|
||||
RET
|
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for 386, Darwin
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, Darwin
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2015 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
|
||||
// +build arm,darwin
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for ARM, Darwin
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
B syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·RawSyscall6(SB)
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2015 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
|
||||
// +build arm64,darwin
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, Darwin
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||
B syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
B syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, DragonFly
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-64
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-88
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-112
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-64
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for 386, FreeBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, FreeBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2012 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"
|
||||
|
||||
//
|
||||
// System call support for ARM, FreeBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
B syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·RawSyscall6(SB)
|
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for 386, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·RawSyscall6(SB)
|
||||
|
||||
TEXT ·socketcall(SB),NOSPLIT,$0-36
|
||||
JMP syscall·socketcall(SB)
|
||||
|
||||
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
|
||||
JMP syscall·rawsocketcall(SB)
|
||||
|
||||
TEXT ·seek(SB),NOSPLIT,$0-28
|
||||
JMP syscall·seek(SB)
|
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for AMD64, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
||||
|
||||
TEXT ·gettimeofday(SB),NOSPLIT,$0-16
|
||||
JMP syscall·gettimeofday(SB)
|
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for arm, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·RawSyscall6(SB)
|
||||
|
||||
TEXT ·seek(SB),NOSPLIT,$0-32
|
||||
B syscall·seek(SB)
|
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2015 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
|
||||
// +build arm64
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
B syscall·RawSyscall6(SB)
|
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2015 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
|
||||
// +build mips64 mips64le
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for mips64, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2014 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
|
||||
// +build ppc64 ppc64le
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for ppc64, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
BR syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
BR syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
BR syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
BR syscall·RawSyscall6(SB)
|
28
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2016 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 s390x
|
||||
// +build linux
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System calls for s390x, Linux
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
BR syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
BR syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
BR syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
BR syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for 386, NetBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, NetBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for ARM, NetBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
B syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
B syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
B syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
B syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for 386, OpenBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
//
|
||||
// System call support for AMD64, OpenBSD
|
||||
//
|
||||
|
||||
// Just jump to package syscall's implementation for all these functions.
|
||||
// The runtime may know about them.
|
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·Syscall(SB)
|
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·Syscall6(SB)
|
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||
JMP syscall·Syscall9(SB)
|
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||
JMP syscall·RawSyscall(SB)
|
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||
JMP syscall·RawSyscall6(SB)
|
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 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"
|
||||
|
||||
//
|
||||
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
||||
//
|
||||
|
||||
TEXT ·sysvicall6(SB),NOSPLIT,$0-64
|
||||
JMP syscall·sysvicall6(SB)
|
||||
|
||||
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64
|
||||
JMP syscall·rawSysvicall6(SB)
|
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// Bluetooth sockets and messages
|
||||
|
||||
package unix
|
||||
|
||||
// Bluetooth Protocols
|
||||
const (
|
||||
BTPROTO_L2CAP = 0
|
||||
BTPROTO_HCI = 1
|
||||
BTPROTO_SCO = 2
|
||||
BTPROTO_RFCOMM = 3
|
||||
BTPROTO_BNEP = 4
|
||||
BTPROTO_CMTP = 5
|
||||
BTPROTO_HIDP = 6
|
||||
BTPROTO_AVDTP = 7
|
||||
)
|
||||
|
||||
const (
|
||||
HCI_CHANNEL_RAW = 0
|
||||
HCI_CHANNEL_USER = 1
|
||||
HCI_CHANNEL_MONITOR = 2
|
||||
HCI_CHANNEL_CONTROL = 3
|
||||
)
|
||||
|
||||
// Socketoption Level
|
||||
const (
|
||||
SOL_BLUETOOTH = 0x112
|
||||
SOL_HCI = 0x0
|
||||
SOL_L2CAP = 0x6
|
||||
SOL_RFCOMM = 0x12
|
||||
SOL_SCO = 0x11
|
||||
)
|
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package unix
|
||||
|
||||
const (
|
||||
R_OK = 0x4
|
||||
W_OK = 0x2
|
||||
X_OK = 0x1
|
||||
)
|
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
// Unix environment variables.
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
||||
func Getenv(key string) (value string, found bool) {
|
||||
return syscall.Getenv(key)
|
||||
}
|
||||
|
||||
func Setenv(key, value string) error {
|
||||
return syscall.Setenv(key, value)
|
||||
}
|
||||
|
||||
func Clearenv() {
|
||||
syscall.Clearenv()
|
||||
}
|
||||
|
||||
func Environ() []string {
|
||||
return syscall.Environ()
|
||||
}
|
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
Normal file
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 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 go1.4
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
||||
func Unsetenv(key string) error {
|
||||
// This was added in Go 1.4.
|
||||
return syscall.Unsetenv(key)
|
||||
}
|
24
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// +build linux darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||
|
||||
package unix
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||
|
||||
// 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 {
|
||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||
if errno == 0 {
|
||||
return nil
|
||||
}
|
||||
return errno
|
||||
}
|
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// +build linux,386 linux,arm
|
||||
|
||||
// Copyright 2014 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 unix
|
||||
|
||||
func init() {
|
||||
// On 32-bit Linux systems, the fcntl syscall that matches Go's
|
||||
// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
|
||||
fcntl64Syscall = SYS_FCNTL64
|
||||
}
|
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2015 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 unix
|
||||
|
||||
import "syscall"
|
||||
|
||||
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
||||
// much of the functionality can be written directly in Go.
|
||||
|
||||
//extern gccgoRealSyscall
|
||||
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
||||
|
||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||
syscall.Entersyscall()
|
||||
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||
syscall.Exitsyscall()
|
||||
return r, 0, syscall.Errno(errno)
|
||||
}
|
||||
|
||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||
syscall.Entersyscall()
|
||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||
syscall.Exitsyscall()
|
||||
return r, 0, syscall.Errno(errno)
|
||||
}
|
||||
|
||||
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||
syscall.Entersyscall()
|
||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||
syscall.Exitsyscall()
|
||||
return r, 0, syscall.Errno(errno)
|
||||
}
|
||||
|
||||
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||
return r, 0, syscall.Errno(errno)
|
||||
}
|
||||
|
||||
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||
return r, 0, syscall.Errno(errno)
|
||||
}
|
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2015 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 <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define _STRINGIFY2_(x) #x
|
||||
#define _STRINGIFY_(x) _STRINGIFY2_(x)
|
||||
#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
|
||||
|
||||
// Call syscall from C code because the gccgo support for calling from
|
||||
// Go to C does not support varargs functions.
|
||||
|
||||
struct ret {
|
||||
uintptr_t r;
|
||||
uintptr_t err;
|
||||
};
|
||||
|
||||
struct ret
|
||||
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||
{
|
||||
struct ret r;
|
||||
|
||||
errno = 0;
|
||||
r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
r.err = errno;
|
||||
return r;
|
||||
}
|
||||
|
||||
// Define the use function in C so that it is not inlined.
|
||||
|
||||
extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
|
||||
|
||||
void
|
||||
use(void *p __attribute__ ((unused)))
|
||||
{
|
||||
}
|
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2015 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,linux,amd64
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
||||
//extern gettimeofday
|
||||
func realGettimeofday(*Timeval, *byte) int32
|
||||
|
||||
func gettimeofday(tv *Timeval) (err syscall.Errno) {
|
||||
r := realGettimeofday(tv, nil)
|
||||
if r < 0 {
|
||||
return syscall.GetErrno()
|
||||
}
|
||||
return 0
|
||||
}
|
62
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
Normal file
62
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright 2016 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 ignore
|
||||
|
||||
// mkpost processes the output of cgo -godefs to
|
||||
// modify the generated types. It is used to clean up
|
||||
// the sys API in an architecture specific manner.
|
||||
//
|
||||
// mkpost is run after cgo -godefs by mkall.sh.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b, err := ioutil.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
s := string(b)
|
||||
|
||||
goarch := os.Getenv("GOARCH")
|
||||
goos := os.Getenv("GOOS")
|
||||
if goarch == "s390x" && goos == "linux" {
|
||||
// Export the types of PtraceRegs fields.
|
||||
re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)")
|
||||
s = re.ReplaceAllString(s, "Ptrace$1")
|
||||
|
||||
// Replace padding fields inserted by cgo with blank identifiers.
|
||||
re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*")
|
||||
s = re.ReplaceAllString(s, "_")
|
||||
|
||||
// Replace other unwanted fields with blank identifiers.
|
||||
re = regexp.MustCompile("X_[A-Za-z0-9_]*")
|
||||
s = re.ReplaceAllString(s, "_")
|
||||
|
||||
// Replace the control_regs union with a blank identifier for now.
|
||||
re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64")
|
||||
s = re.ReplaceAllString(s, "_ [0]uint64")
|
||||
}
|
||||
|
||||
// gofmt
|
||||
b, err = format.Source([]byte(s))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Append this command to the header to show where the new file
|
||||
// came from.
|
||||
re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)")
|
||||
b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go"))
|
||||
|
||||
fmt.Printf("%s", b)
|
||||
}
|
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin,race linux,race freebsd,race
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const raceenabled = true
|
||||
|
||||
func raceAcquire(addr unsafe.Pointer) {
|
||||
runtime.RaceAcquire(addr)
|
||||
}
|
||||
|
||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||
runtime.RaceReleaseMerge(addr)
|
||||
}
|
||||
|
||||
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||
runtime.RaceReadRange(addr, len)
|
||||
}
|
||||
|
||||
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||
runtime.RaceWriteRange(addr, len)
|
||||
}
|
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const raceenabled = false
|
||||
|
||||
func raceAcquire(addr unsafe.Pointer) {
|
||||
}
|
||||
|
||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||
}
|
||||
|
||||
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||
}
|
||||
|
||||
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||
}
|
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2011 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.
|
||||
|
||||
// Socket control messages
|
||||
|
||||
package unix
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// UnixCredentials encodes credentials into a socket control message
|
||||
// for sending to another process. This can be used for
|
||||
// authentication.
|
||||
func UnixCredentials(ucred *Ucred) []byte {
|
||||
b := make([]byte, CmsgSpace(SizeofUcred))
|
||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||
h.Level = SOL_SOCKET
|
||||
h.Type = SCM_CREDENTIALS
|
||||
h.SetLen(CmsgLen(SizeofUcred))
|
||||
*((*Ucred)(cmsgData(h))) = *ucred
|
||||
return b
|
||||
}
|
||||
|
||||
// ParseUnixCredentials decodes a socket control message that contains
|
||||
// credentials in a Ucred structure. To receive such a message, the
|
||||
// SO_PASSCRED option must be enabled on the socket.
|
||||
func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
|
||||
if m.Header.Level != SOL_SOCKET {
|
||||
return nil, EINVAL
|
||||
}
|
||||
if m.Header.Type != SCM_CREDENTIALS {
|
||||
return nil, EINVAL
|
||||
}
|
||||
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
|
||||
return &ucred, nil
|
||||
}
|
103
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
103
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
// Socket control messages
|
||||
|
||||
package unix
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Round the length of a raw sockaddr up to align it properly.
|
||||
func cmsgAlignOf(salen int) int {
|
||||
salign := sizeofPtr
|
||||
// NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
|
||||
// still require 32-bit aligned access to network subsystem.
|
||||
if darwin64Bit || dragonfly64Bit {
|
||||
salign = 4
|
||||
}
|
||||
return (salen + salign - 1) & ^(salign - 1)
|
||||
}
|
||||
|
||||
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
||||
// structure, taking into account any necessary alignment.
|
||||
func CmsgLen(datalen int) int {
|
||||
return cmsgAlignOf(SizeofCmsghdr) + datalen
|
||||
}
|
||||
|
||||
// CmsgSpace returns the number of bytes an ancillary element with
|
||||
// payload of the passed data length occupies.
|
||||
func CmsgSpace(datalen int) int {
|
||||
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
||||
}
|
||||
|
||||
func cmsgData(h *Cmsghdr) unsafe.Pointer {
|
||||
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
|
||||
}
|
||||
|
||||
// SocketControlMessage represents a socket control message.
|
||||
type SocketControlMessage struct {
|
||||
Header Cmsghdr
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// ParseSocketControlMessage parses b as an array of socket control
|
||||
// messages.
|
||||
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
|
||||
var msgs []SocketControlMessage
|
||||
i := 0
|
||||
for i+CmsgLen(0) <= len(b) {
|
||||
h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m := SocketControlMessage{Header: *h, Data: dbuf}
|
||||
msgs = append(msgs, m)
|
||||
i += cmsgAlignOf(int(h.Len))
|
||||
}
|
||||
return msgs, nil
|
||||
}
|
||||
|
||||
func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
|
||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||
if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
|
||||
return nil, nil, EINVAL
|
||||
}
|
||||
return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
|
||||
}
|
||||
|
||||
// UnixRights encodes a set of open file descriptors into a socket
|
||||
// control message for sending to another process.
|
||||
func UnixRights(fds ...int) []byte {
|
||||
datalen := len(fds) * 4
|
||||
b := make([]byte, CmsgSpace(datalen))
|
||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||
h.Level = SOL_SOCKET
|
||||
h.Type = SCM_RIGHTS
|
||||
h.SetLen(CmsgLen(datalen))
|
||||
data := cmsgData(h)
|
||||
for _, fd := range fds {
|
||||
*(*int32)(data) = int32(fd)
|
||||
data = unsafe.Pointer(uintptr(data) + 4)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// ParseUnixRights decodes a socket control message that contains an
|
||||
// integer array of open file descriptors from another process.
|
||||
func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
|
||||
if m.Header.Level != SOL_SOCKET {
|
||||
return nil, EINVAL
|
||||
}
|
||||
if m.Header.Type != SCM_RIGHTS {
|
||||
return nil, EINVAL
|
||||
}
|
||||
fds := make([]int, len(m.Data)>>2)
|
||||
for i, j := 0, 0; i < len(m.Data); i += 4 {
|
||||
fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
|
||||
j++
|
||||
}
|
||||
return fds, nil
|
||||
}
|
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// 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.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package unix
|
||||
|
||||
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + uitoa(uint(-val))
|
||||
}
|
||||
return uitoa(uint(val))
|
||||
}
|
||||
|
||||
func uitoa(val uint) string {
|
||||
var buf [32]byte // big enough for int64
|
||||
i := len(buf) - 1
|
||||
for val >= 10 {
|
||||
buf[i] = byte(val%10 + '0')
|
||||
i--
|
||||
val /= 10
|
||||
}
|
||||
buf[i] = byte(val + '0')
|
||||
return string(buf[i:])
|
||||
}
|
76
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
76
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
// 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.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
// Package unix contains an interface to the low-level operating system
|
||||
// primitives. OS details vary depending on the underlying system, and
|
||||
// by default, godoc will display OS-specific documentation for the current
|
||||
// system. If you want godoc to display OS documentation for another
|
||||
// system, set $GOOS and $GOARCH to the desired system. For example, if
|
||||
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
|
||||
// to freebsd and $GOARCH to arm.
|
||||
// The primary use of this package is inside other packages that provide a more
|
||||
// portable interface to the system, such as "os", "time" and "net". Use
|
||||
// those packages rather than this one if you can.
|
||||
// For details of the functions and data types in this package consult
|
||||
// the manuals for the appropriate operating system.
|
||||
// These calls return err == nil to indicate success; otherwise
|
||||
// err represents an operating system error describing the failure and
|
||||
// holds a value of type syscall.Errno.
|
||||
package unix // import "golang.org/x/sys/unix"
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
||||
// containing the text of s. If s contains a NUL byte at any
|
||||
// location, it returns (nil, EINVAL).
|
||||
func ByteSliceFromString(s string) ([]byte, error) {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == 0 {
|
||||
return nil, EINVAL
|
||||
}
|
||||
}
|
||||
a := make([]byte, len(s)+1)
|
||||
copy(a, s)
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// BytePtrFromString returns a pointer to a NUL-terminated array of
|
||||
// bytes containing the text of s. If s contains a NUL byte at any
|
||||
// location, it returns (nil, EINVAL).
|
||||
func BytePtrFromString(s string) (*byte, error) {
|
||||
a, err := ByteSliceFromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &a[0], nil
|
||||
}
|
||||
|
||||
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||
// See mkunix.pl.
|
||||
var _zero uintptr
|
||||
|
||||
func (ts *Timespec) Unix() (sec int64, nsec int64) {
|
||||
return int64(ts.Sec), int64(ts.Nsec)
|
||||
}
|
||||
|
||||
func (tv *Timeval) Unix() (sec int64, nsec int64) {
|
||||
return int64(tv.Sec), int64(tv.Usec) * 1000
|
||||
}
|
||||
|
||||
func (ts *Timespec) Nano() int64 {
|
||||
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
|
||||
}
|
||||
|
||||
func (tv *Timeval) Nano() int64 {
|
||||
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
|
||||
}
|
||||
|
||||
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
|
||||
|
||||
// use is a no-op, but the compiler cannot see that it is.
|
||||
// Calling use(p) ensures that p is kept live until that point.
|
||||
//go:noescape
|
||||
func use(p unsafe.Pointer)
|
628
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
628
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
@ -0,0 +1,628 @@
|
||||
// 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.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
// BSD system call wrappers shared by *BSD based systems
|
||||
// including OS X (Darwin) and FreeBSD. Like the other
|
||||
// syscall_*.go files it is compiled as Go code but also
|
||||
// used as input to mksyscall which parses the //sys
|
||||
// lines and generates system call stubs.
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
/*
|
||||
* Wrapped
|
||||
*/
|
||||
|
||||
//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
|
||||
//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
|
||||
|
||||
func Getgroups() (gids []int, err error) {
|
||||
n, err := getgroups(0, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if n == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Sanity check group count. Max is 16 on BSD.
|
||||
if n < 0 || n > 1000 {
|
||||
return nil, EINVAL
|
||||
}
|
||||
|
||||
a := make([]_Gid_t, n)
|
||||
n, err = getgroups(n, &a[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gids = make([]int, n)
|
||||
for i, v := range a[0:n] {
|
||||
gids[i] = int(v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Setgroups(gids []int) (err error) {
|
||||
if len(gids) == 0 {
|
||||
return setgroups(0, nil)
|
||||
}
|
||||
|
||||
a := make([]_Gid_t, len(gids))
|
||||
for i, v := range gids {
|
||||
a[i] = _Gid_t(v)
|
||||
}
|
||||
return setgroups(len(a), &a[0])
|
||||
}
|
||||
|
||||
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||
// Final argument is (basep *uintptr) and the syscall doesn't take nil.
|
||||
// 64 bits should be enough. (32 bits isn't even on 386). Since the
|
||||
// actual system call is getdirentries64, 64 is a good guess.
|
||||
// TODO(rsc): Can we use a single global basep for all calls?
|
||||
var base = (*uintptr)(unsafe.Pointer(new(uint64)))
|
||||
return Getdirentries(fd, buf, base)
|
||||
}
|
||||
|
||||
// Wait status is 7 bits at bottom, either 0 (exited),
|
||||
// 0x7F (stopped), or a signal number that caused an exit.
|
||||
// The 0x80 bit is whether there was a core dump.
|
||||
// An extra number (exit code, signal causing a stop)
|
||||
// is in the high bits.
|
||||
|
||||
type WaitStatus uint32
|
||||
|
||||
const (
|
||||
mask = 0x7F
|
||||
core = 0x80
|
||||
shift = 8
|
||||
|
||||
exited = 0
|
||||
stopped = 0x7F
|
||||
)
|
||||
|
||||
func (w WaitStatus) Exited() bool { return w&mask == exited }
|
||||
|
||||
func (w WaitStatus) ExitStatus() int {
|
||||
if w&mask != exited {
|
||||
return -1
|
||||
}
|
||||
return int(w >> shift)
|
||||
}
|
||||
|
||||
func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
|
||||
|
||||
func (w WaitStatus) Signal() syscall.Signal {
|
||||
sig := syscall.Signal(w & mask)
|
||||
if sig == stopped || sig == 0 {
|
||||
return -1
|
||||
}
|
||||
return sig
|
||||
}
|
||||
|
||||
func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
|
||||
|
||||
func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
|
||||
|
||||
func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
|
||||
|
||||
func (w WaitStatus) StopSignal() syscall.Signal {
|
||||
if !w.Stopped() {
|
||||
return -1
|
||||
}
|
||||
return syscall.Signal(w>>shift) & 0xFF
|
||||
}
|
||||
|
||||
func (w WaitStatus) TrapCause() int { return -1 }
|
||||
|
||||
//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
|
||||
|
||||
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||
var status _C_int
|
||||
wpid, err = wait4(pid, &status, options, rusage)
|
||||
if wstatus != nil {
|
||||
*wstatus = WaitStatus(status)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sys Shutdown(s int, how int) (err error)
|
||||
|
||||
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||
return nil, 0, EINVAL
|
||||
}
|
||||
sa.raw.Len = SizeofSockaddrInet4
|
||||
sa.raw.Family = AF_INET
|
||||
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||
p[0] = byte(sa.Port >> 8)
|
||||
p[1] = byte(sa.Port)
|
||||
for i := 0; i < len(sa.Addr); i++ {
|
||||
sa.raw.Addr[i] = sa.Addr[i]
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||
}
|
||||
|
||||
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||
return nil, 0, EINVAL
|
||||
}
|
||||
sa.raw.Len = SizeofSockaddrInet6
|
||||
sa.raw.Family = AF_INET6
|
||||
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||
p[0] = byte(sa.Port >> 8)
|
||||
p[1] = byte(sa.Port)
|
||||
sa.raw.Scope_id = sa.ZoneId
|
||||
for i := 0; i < len(sa.Addr); i++ {
|
||||
sa.raw.Addr[i] = sa.Addr[i]
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||
}
|
||||
|
||||
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||
name := sa.Name
|
||||
n := len(name)
|
||||
if n >= len(sa.raw.Path) || n == 0 {
|
||||
return nil, 0, EINVAL
|
||||
}
|
||||
sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
|
||||
sa.raw.Family = AF_UNIX
|
||||
for i := 0; i < n; i++ {
|
||||
sa.raw.Path[i] = int8(name[i])
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||
}
|
||||
|
||||
func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||
if sa.Index == 0 {
|
||||
return nil, 0, EINVAL
|
||||
}
|
||||
sa.raw.Len = sa.Len
|
||||
sa.raw.Family = AF_LINK
|
||||
sa.raw.Index = sa.Index
|
||||
sa.raw.Type = sa.Type
|
||||
sa.raw.Nlen = sa.Nlen
|
||||
sa.raw.Alen = sa.Alen
|
||||
sa.raw.Slen = sa.Slen
|
||||
for i := 0; i < len(sa.raw.Data); i++ {
|
||||
sa.raw.Data[i] = sa.Data[i]
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
|
||||
}
|
||||
|
||||
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||
switch rsa.Addr.Family {
|
||||
case AF_LINK:
|
||||
pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
|
||||
sa := new(SockaddrDatalink)
|
||||
sa.Len = pp.Len
|
||||
sa.Family = pp.Family
|
||||
sa.Index = pp.Index
|
||||
sa.Type = pp.Type
|
||||
sa.Nlen = pp.Nlen
|
||||
sa.Alen = pp.Alen
|
||||
sa.Slen = pp.Slen
|
||||
for i := 0; i < len(sa.Data); i++ {
|
||||
sa.Data[i] = pp.Data[i]
|
||||
}
|
||||
return sa, nil
|
||||
|
||||
case AF_UNIX:
|
||||
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||
if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
|
||||
return nil, EINVAL
|
||||
}
|
||||
sa := new(SockaddrUnix)
|
||||
|
||||
// Some BSDs include the trailing NUL in the length, whereas
|
||||
// others do not. Work around this by subtracting the leading
|
||||
// family and len. The path is then scanned to see if a NUL
|
||||
// terminator still exists within the length.
|
||||
n := int(pp.Len) - 2 // subtract leading Family, Len
|
||||
for i := 0; i < n; i++ {
|
||||
if pp.Path[i] == 0 {
|
||||
// found early NUL; assume Len included the NUL
|
||||
// or was overestimating.
|
||||
n = i
|
||||
break
|
||||
}
|
||||
}
|
||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||
sa.Name = string(bytes)
|
||||
return sa, nil
|
||||
|
||||
case AF_INET:
|
||||
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
|
||||
sa := new(SockaddrInet4)
|
||||
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||
sa.Port = int(p[0])<<8 + int(p[1])
|
||||
for i := 0; i < len(sa.Addr); i++ {
|
||||
sa.Addr[i] = pp.Addr[i]
|
||||
}
|
||||
return sa, nil
|
||||
|
||||
case AF_INET6:
|
||||
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
|
||||
sa := new(SockaddrInet6)
|
||||
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||
sa.Port = int(p[0])<<8 + int(p[1])
|
||||
sa.ZoneId = pp.Scope_id
|
||||
for i := 0; i < len(sa.Addr); i++ {
|
||||
sa.Addr[i] = pp.Addr[i]
|
||||
}
|
||||
return sa, nil
|
||||
}
|
||||
return nil, EAFNOSUPPORT
|
||||
}
|
||||
|
||||
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||
var rsa RawSockaddrAny
|
||||
var len _Socklen = SizeofSockaddrAny
|
||||
nfd, err = accept(fd, &rsa, &len)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if runtime.GOOS == "darwin" && len == 0 {
|
||||
// Accepted socket has no address.
|
||||
// This is likely due to a bug in xnu kernels,
|
||||
// where instead of ECONNABORTED error socket
|
||||
// is accepted, but has no address.
|
||||
Close(nfd)
|
||||
return 0, nil, ECONNABORTED
|
||||
}
|
||||
sa, err = anyToSockaddr(&rsa)
|
||||
if err != nil {
|
||||
Close(nfd)
|
||||
nfd = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||
var rsa RawSockaddrAny
|
||||
var len _Socklen = SizeofSockaddrAny
|
||||
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||
return
|
||||
}
|
||||
// TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
|
||||
// reported upstream.
|
||||
if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
|
||||
rsa.Addr.Family = AF_UNIX
|
||||
rsa.Addr.Len = SizeofSockaddrUnix
|
||||
}
|
||||
return anyToSockaddr(&rsa)
|
||||
}
|
||||
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
|
||||
func GetsockoptByte(fd, level, opt int) (value byte, err error) {
|
||||
var n byte
|
||||
vallen := _Socklen(1)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
|
||||
vallen := _Socklen(4)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
|
||||
var value IPMreq
|
||||
vallen := _Socklen(SizeofIPMreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
|
||||
var value IPv6Mreq
|
||||
vallen := _Socklen(SizeofIPv6Mreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
|
||||
var value IPv6MTUInfo
|
||||
vallen := _Socklen(SizeofIPv6MTUInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
|
||||
var value ICMPv6Filter
|
||||
vallen := _Socklen(SizeofICMPv6Filter)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
|
||||
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||
var msg Msghdr
|
||||
var rsa RawSockaddrAny
|
||||
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
||||
msg.Namelen = uint32(SizeofSockaddrAny)
|
||||
var iov Iovec
|
||||
if len(p) > 0 {
|
||||
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||
iov.SetLen(len(p))
|
||||
}
|
||||
var dummy byte
|
||||
if len(oob) > 0 {
|
||||
// receive at least one normal byte
|
||||
if len(p) == 0 {
|
||||
iov.Base = &dummy
|
||||
iov.SetLen(1)
|
||||
}
|
||||
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||
msg.SetControllen(len(oob))
|
||||
}
|
||||
msg.Iov = &iov
|
||||
msg.Iovlen = 1
|
||||
if n, err = recvmsg(fd, &msg, flags); err != nil {
|
||||
return
|
||||
}
|
||||
oobn = int(msg.Controllen)
|
||||
recvflags = int(msg.Flags)
|
||||
// source address is only specified if the socket is unconnected
|
||||
if rsa.Addr.Family != AF_UNSPEC {
|
||||
from, err = anyToSockaddr(&rsa)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
|
||||
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
|
||||
_, err = SendmsgN(fd, p, oob, to, flags)
|
||||
return
|
||||
}
|
||||
|
||||
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
|
||||
var ptr unsafe.Pointer
|
||||
var salen _Socklen
|
||||
if to != nil {
|
||||
ptr, salen, err = to.sockaddr()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
var msg Msghdr
|
||||
msg.Name = (*byte)(unsafe.Pointer(ptr))
|
||||
msg.Namelen = uint32(salen)
|
||||
var iov Iovec
|
||||
if len(p) > 0 {
|
||||
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||
iov.SetLen(len(p))
|
||||
}
|
||||
var dummy byte
|
||||
if len(oob) > 0 {
|
||||
// send at least one normal byte
|
||||
if len(p) == 0 {
|
||||
iov.Base = &dummy
|
||||
iov.SetLen(1)
|
||||
}
|
||||
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||
msg.SetControllen(len(oob))
|
||||
}
|
||||
msg.Iov = &iov
|
||||
msg.Iovlen = 1
|
||||
if n, err = sendmsg(fd, &msg, flags); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if len(oob) > 0 && len(p) == 0 {
|
||||
n = 0
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
|
||||
|
||||
func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
|
||||
var change, event unsafe.Pointer
|
||||
if len(changes) > 0 {
|
||||
change = unsafe.Pointer(&changes[0])
|
||||
}
|
||||
if len(events) > 0 {
|
||||
event = unsafe.Pointer(&events[0])
|
||||
}
|
||||
return kevent(kq, change, len(changes), event, len(events), timeout)
|
||||
}
|
||||
|
||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
||||
|
||||
// sysctlmib translates name to mib number and appends any additional args.
|
||||
func sysctlmib(name string, args ...int) ([]_C_int, error) {
|
||||
// Translate name to mib number.
|
||||
mib, err := nametomib(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, a := range args {
|
||||
mib = append(mib, _C_int(a))
|
||||
}
|
||||
|
||||
return mib, nil
|
||||
}
|
||||
|
||||
func Sysctl(name string) (string, error) {
|
||||
return SysctlArgs(name)
|
||||
}
|
||||
|
||||
func SysctlArgs(name string, args ...int) (string, error) {
|
||||
mib, err := sysctlmib(name, args...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Find size.
|
||||
n := uintptr(0)
|
||||
if err := sysctl(mib, nil, &n, nil, 0); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if n == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Read into buffer of that size.
|
||||
buf := make([]byte, n)
|
||||
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Throw away terminating NUL.
|
||||
if n > 0 && buf[n-1] == '\x00' {
|
||||
n--
|
||||
}
|
||||
return string(buf[0:n]), nil
|
||||
}
|
||||
|
||||
func SysctlUint32(name string) (uint32, error) {
|
||||
return SysctlUint32Args(name)
|
||||
}
|
||||
|
||||
func SysctlUint32Args(name string, args ...int) (uint32, error) {
|
||||
mib, err := sysctlmib(name, args...)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
n := uintptr(4)
|
||||
buf := make([]byte, 4)
|
||||
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if n != 4 {
|
||||
return 0, EIO
|
||||
}
|
||||
return *(*uint32)(unsafe.Pointer(&buf[0])), nil
|
||||
}
|
||||
|
||||
func SysctlUint64(name string, args ...int) (uint64, error) {
|
||||
mib, err := sysctlmib(name, args...)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
n := uintptr(8)
|
||||
buf := make([]byte, 8)
|
||||
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if n != 8 {
|
||||
return 0, EIO
|
||||
}
|
||||
return *(*uint64)(unsafe.Pointer(&buf[0])), nil
|
||||
}
|
||||
|
||||
func SysctlRaw(name string, args ...int) ([]byte, error) {
|
||||
mib, err := sysctlmib(name, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Find size.
|
||||
n := uintptr(0)
|
||||
if err := sysctl(mib, nil, &n, nil, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if n == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Read into buffer of that size.
|
||||
buf := make([]byte, n)
|
||||
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The actual call may return less than the original reported required
|
||||
// size so ensure we deal with that.
|
||||
return buf[:n], nil
|
||||
}
|
||||
|
||||
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
||||
|
||||
func Utimes(path string, tv []Timeval) error {
|
||||
if tv == nil {
|
||||
return utimes(path, nil)
|
||||
}
|
||||
if len(tv) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||
}
|
||||
|
||||
func UtimesNano(path string, ts []Timespec) error {
|
||||
if ts == nil {
|
||||
return utimes(path, nil)
|
||||
}
|
||||
// TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
|
||||
// isn't supported by darwin so this uses utimes instead
|
||||
if len(ts) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
// Not as efficient as it could be because Timespec and
|
||||
// Timeval have different types in the different OSes
|
||||
tv := [2]Timeval{
|
||||
NsecToTimeval(TimespecToNsec(ts[0])),
|
||||
NsecToTimeval(TimespecToNsec(ts[1])),
|
||||
}
|
||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||
}
|
||||
|
||||
//sys futimes(fd int, timeval *[2]Timeval) (err error)
|
||||
|
||||
func Futimes(fd int, tv []Timeval) error {
|
||||
if tv == nil {
|
||||
return futimes(fd, nil)
|
||||
}
|
||||
if len(tv) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||
}
|
||||
|
||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||
|
||||
// TODO: wrap
|
||||
// Acct(name nil-string) (err error)
|
||||
// Gethostuuid(uuid *byte, timeout *Timespec) (err error)
|
||||
// Madvise(addr *byte, len int, behav int) (err error)
|
||||
// Mprotect(addr *byte, len int, prot int) (err error)
|
||||
// Msync(addr *byte, len int, flags int) (err error)
|
||||
// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
|
||||
|
||||
var mapper = &mmapper{
|
||||
active: make(map[*byte][]byte),
|
||||
mmap: mmap,
|
||||
munmap: munmap,
|
||||
}
|
||||
|
||||
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||
return mapper.Mmap(fd, offset, length, prot, flags)
|
||||
}
|
||||
|
||||
func Munmap(b []byte) (err error) {
|
||||
return mapper.Munmap(b)
|
||||
}
|
511
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
511
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
@ -0,0 +1,511 @@
|
||||
// Copyright 2009,2010 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.
|
||||
|
||||
// Darwin system calls.
|
||||
// This file is compiled as ordinary Go code,
|
||||
// but it is also input to mksyscall,
|
||||
// which parses the //sys lines and generates system call stubs.
|
||||
// Note that sometimes we use a lowercase //sys name and wrap
|
||||
// it in our own nicer implementation, either here or in
|
||||
// syscall_bsd.go or syscall_unix.go.
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
errorspkg "errors"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const ImplementsGetwd = true
|
||||
|
||||
func Getwd() (string, error) {
|
||||
buf := make([]byte, 2048)
|
||||
attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
|
||||
if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
|
||||
wd := string(attrs[0])
|
||||
// Sanity check that it's an absolute path and ends
|
||||
// in a null byte, which we then strip.
|
||||
if wd[0] == '/' && wd[len(wd)-1] == 0 {
|
||||
return wd[:len(wd)-1], nil
|
||||
}
|
||||
}
|
||||
// If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
|
||||
// slow algorithm.
|
||||
return "", ENOTSUP
|
||||
}
|
||||
|
||||
type SockaddrDatalink struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Index uint16
|
||||
Type uint8
|
||||
Nlen uint8
|
||||
Alen uint8
|
||||
Slen uint8
|
||||
Data [12]int8
|
||||
raw RawSockaddrDatalink
|
||||
}
|
||||
|
||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||
func nametomib(name string) (mib []_C_int, err error) {
|
||||
const siz = unsafe.Sizeof(mib[0])
|
||||
|
||||
// NOTE(rsc): It seems strange to set the buffer to have
|
||||
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||
// as the size. I don't know why the +2 is here, but the
|
||||
// kernel uses +2 for its own implementation of this function.
|
||||
// I am scared that if we don't include the +2 here, the kernel
|
||||
// will silently write 2 words farther than we specify
|
||||
// and we'll get memory corruption.
|
||||
var buf [CTL_MAXNAME + 2]_C_int
|
||||
n := uintptr(CTL_MAXNAME) * siz
|
||||
|
||||
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||
bytes, err := ByteSliceFromString(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Magic sysctl: "setting" 0.3 to a string name
|
||||
// lets you read back the array of integers form.
|
||||
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf[0 : n/siz], nil
|
||||
}
|
||||
|
||||
// ParseDirent parses up to max directory entries in buf,
|
||||
// appending the names to names. It returns the number
|
||||
// bytes consumed from buf, the number of entries added
|
||||
// to names, and the new names slice.
|
||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||
origlen := len(buf)
|
||||
for max != 0 && len(buf) > 0 {
|
||||
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||
if dirent.Reclen == 0 {
|
||||
buf = nil
|
||||
break
|
||||
}
|
||||
buf = buf[dirent.Reclen:]
|
||||
if dirent.Ino == 0 { // File absent in directory.
|
||||
continue
|
||||
}
|
||||
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||
var name = string(bytes[0:dirent.Namlen])
|
||||
if name == "." || name == ".." { // Useless names
|
||||
continue
|
||||
}
|
||||
max--
|
||||
count++
|
||||
names = append(names, name)
|
||||
}
|
||||
return origlen - len(buf), count, names
|
||||
}
|
||||
|
||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
||||
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
||||
|
||||
const (
|
||||
attrBitMapCount = 5
|
||||
attrCmnFullpath = 0x08000000
|
||||
)
|
||||
|
||||
type attrList struct {
|
||||
bitmapCount uint16
|
||||
_ uint16
|
||||
CommonAttr uint32
|
||||
VolAttr uint32
|
||||
DirAttr uint32
|
||||
FileAttr uint32
|
||||
Forkattr uint32
|
||||
}
|
||||
|
||||
func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
|
||||
if len(attrBuf) < 4 {
|
||||
return nil, errorspkg.New("attrBuf too small")
|
||||
}
|
||||
attrList.bitmapCount = attrBitMapCount
|
||||
|
||||
var _p0 *byte
|
||||
_p0, err = BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, _, e1 := Syscall6(
|
||||
SYS_GETATTRLIST,
|
||||
uintptr(unsafe.Pointer(_p0)),
|
||||
uintptr(unsafe.Pointer(&attrList)),
|
||||
uintptr(unsafe.Pointer(&attrBuf[0])),
|
||||
uintptr(len(attrBuf)),
|
||||
uintptr(options),
|
||||
0,
|
||||
)
|
||||
use(unsafe.Pointer(_p0))
|
||||
if e1 != 0 {
|
||||
return nil, e1
|
||||
}
|
||||
size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
|
||||
|
||||
// dat is the section of attrBuf that contains valid data,
|
||||
// without the 4 byte length header. All attribute offsets
|
||||
// are relative to dat.
|
||||
dat := attrBuf
|
||||
if int(size) < len(attrBuf) {
|
||||
dat = dat[:size]
|
||||
}
|
||||
dat = dat[4:] // remove length prefix
|
||||
|
||||
for i := uint32(0); int(i) < len(dat); {
|
||||
header := dat[i:]
|
||||
if len(header) < 8 {
|
||||
return attrs, errorspkg.New("truncated attribute header")
|
||||
}
|
||||
datOff := *(*int32)(unsafe.Pointer(&header[0]))
|
||||
attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
|
||||
if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
|
||||
return attrs, errorspkg.New("truncated results; attrBuf too small")
|
||||
}
|
||||
end := uint32(datOff) + attrLen
|
||||
attrs = append(attrs, dat[datOff:end])
|
||||
i = end
|
||||
if r := i % 4; r != 0 {
|
||||
i += (4 - r)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//sysnb pipe() (r int, w int, err error)
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
p[0], p[1], err = pipe()
|
||||
return
|
||||
}
|
||||
|
||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
var bufsize uintptr
|
||||
if len(buf) > 0 {
|
||||
_p0 = unsafe.Pointer(&buf[0])
|
||||
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||
}
|
||||
r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
|
||||
use(unsafe.Pointer(_p0))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapped
|
||||
*/
|
||||
|
||||
//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) }
|
||||
|
||||
/*
|
||||
* Exposed directly
|
||||
*/
|
||||
//sys Access(path string, mode uint32) (err error)
|
||||
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||
//sys Chdir(path string) (err error)
|
||||
//sys Chflags(path string, flags int) (err error)
|
||||
//sys Chmod(path string, mode uint32) (err error)
|
||||
//sys Chown(path string, uid int, gid int) (err error)
|
||||
//sys Chroot(path string) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys Dup(fd int) (nfd int, err error)
|
||||
//sys Dup2(from int, to int) (err error)
|
||||
//sys Exchangedata(path1 string, path2 string, options int) (err error)
|
||||
//sys Exit(code int)
|
||||
//sys Fchdir(fd int) (err error)
|
||||
//sys Fchflags(fd int, flags int) (err error)
|
||||
//sys Fchmod(fd int, mode uint32) (err error)
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Flock(fd int, how int) (err error)
|
||||
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||
//sys Fsync(fd int) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
||||
//sys Getdtablesize() (size int)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (uid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||
//sysnb Getpgrp() (pgrp int)
|
||||
//sysnb Getpid() (pid int)
|
||||
//sysnb Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (prio int, err error)
|
||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getsid(pid int) (sid int, err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sysnb Issetugid() (tainted bool)
|
||||
//sys Kqueue() (fd int, err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Link(path string, link string) (err error)
|
||||
//sys Listen(s int, backlog int) (err error)
|
||||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||
//sys Mkdir(path string, mode uint32) (err error)
|
||||
//sys Mkfifo(path string, mode uint32) (err error)
|
||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||
//sys Mlock(b []byte) (err error)
|
||||
//sys Mlockall(flags int) (err error)
|
||||
//sys Mprotect(b []byte, prot int) (err error)
|
||||
//sys Munlock(b []byte) (err error)
|
||||
//sys Munlockall() (err error)
|
||||
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||
//sys Pathconf(path string, name int) (val int, err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||
//sys read(fd int, p []byte) (n int, err error)
|
||||
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||
//sys Rename(from string, to string) (err error)
|
||||
//sys Revoke(path string) (err error)
|
||||
//sys Rmdir(path string) (err error)
|
||||
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||
//sys Setegid(egid int) (err error)
|
||||
//sysnb Seteuid(euid int) (err error)
|
||||
//sysnb Setgid(gid int) (err error)
|
||||
//sys Setlogin(name string) (err error)
|
||||
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||
//sys Setpriority(which int, who int, prio int) (err error)
|
||||
//sys Setprivexec(flag int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Setsid() (pid int, err error)
|
||||
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||
//sysnb Setuid(uid int) (err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||
//sys Symlink(path string, link string) (err error)
|
||||
//sys Sync() (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
//sys Umask(newmask int) (oldmask int)
|
||||
//sys Undelete(path string) (err error)
|
||||
//sys Unlink(path string) (err error)
|
||||
//sys Unmount(path string, flags int) (err error)
|
||||
//sys write(fd int, p []byte) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
*/
|
||||
// Profil
|
||||
// Sigaction
|
||||
// Sigprocmask
|
||||
// Getlogin
|
||||
// Sigpending
|
||||
// Sigaltstack
|
||||
// Ioctl
|
||||
// Reboot
|
||||
// Execve
|
||||
// Vfork
|
||||
// Sbrk
|
||||
// Sstk
|
||||
// Ovadvise
|
||||
// Mincore
|
||||
// Setitimer
|
||||
// Swapon
|
||||
// Select
|
||||
// Sigsuspend
|
||||
// Readv
|
||||
// Writev
|
||||
// Nfssvc
|
||||
// Getfh
|
||||
// Quotactl
|
||||
// Mount
|
||||
// Csops
|
||||
// Waitid
|
||||
// Add_profil
|
||||
// Kdebug_trace
|
||||
// Sigreturn
|
||||
// Mmap
|
||||
// Mlock
|
||||
// Munlock
|
||||
// Atsocket
|
||||
// Kqueue_from_portset_np
|
||||
// Kqueue_portset
|
||||
// Getattrlist
|
||||
// Setattrlist
|
||||
// Getdirentriesattr
|
||||
// Searchfs
|
||||
// Delete
|
||||
// Copyfile
|
||||
// Poll
|
||||
// Watchevent
|
||||
// Waitevent
|
||||
// Modwatch
|
||||
// Getxattr
|
||||
// Fgetxattr
|
||||
// Setxattr
|
||||
// Fsetxattr
|
||||
// Removexattr
|
||||
// Fremovexattr
|
||||
// Listxattr
|
||||
// Flistxattr
|
||||
// Fsctl
|
||||
// Initgroups
|
||||
// Posix_spawn
|
||||
// Nfsclnt
|
||||
// Fhopen
|
||||
// Minherit
|
||||
// Semsys
|
||||
// Msgsys
|
||||
// Shmsys
|
||||
// Semctl
|
||||
// Semget
|
||||
// Semop
|
||||
// Msgctl
|
||||
// Msgget
|
||||
// Msgsnd
|
||||
// Msgrcv
|
||||
// Shmat
|
||||
// Shmctl
|
||||
// Shmdt
|
||||
// Shmget
|
||||
// Shm_open
|
||||
// Shm_unlink
|
||||
// Sem_open
|
||||
// Sem_close
|
||||
// Sem_unlink
|
||||
// Sem_wait
|
||||
// Sem_trywait
|
||||
// Sem_post
|
||||
// Sem_getvalue
|
||||
// Sem_init
|
||||
// Sem_destroy
|
||||
// Open_extended
|
||||
// Umask_extended
|
||||
// Stat_extended
|
||||
// Lstat_extended
|
||||
// Fstat_extended
|
||||
// Chmod_extended
|
||||
// Fchmod_extended
|
||||
// Access_extended
|
||||
// Settid
|
||||
// Gettid
|
||||
// Setsgroups
|
||||
// Getsgroups
|
||||
// Setwgroups
|
||||
// Getwgroups
|
||||
// Mkfifo_extended
|
||||
// Mkdir_extended
|
||||
// Identitysvc
|
||||
// Shared_region_check_np
|
||||
// Shared_region_map_np
|
||||
// __pthread_mutex_destroy
|
||||
// __pthread_mutex_init
|
||||
// __pthread_mutex_lock
|
||||
// __pthread_mutex_trylock
|
||||
// __pthread_mutex_unlock
|
||||
// __pthread_cond_init
|
||||
// __pthread_cond_destroy
|
||||
// __pthread_cond_broadcast
|
||||
// __pthread_cond_signal
|
||||
// Setsid_with_pid
|
||||
// __pthread_cond_timedwait
|
||||
// Aio_fsync
|
||||
// Aio_return
|
||||
// Aio_suspend
|
||||
// Aio_cancel
|
||||
// Aio_error
|
||||
// Aio_read
|
||||
// Aio_write
|
||||
// Lio_listio
|
||||
// __pthread_cond_wait
|
||||
// Iopolicysys
|
||||
// Mlockall
|
||||
// Munlockall
|
||||
// __pthread_kill
|
||||
// __pthread_sigmask
|
||||
// __sigwait
|
||||
// __disable_threadsignal
|
||||
// __pthread_markcancel
|
||||
// __pthread_canceled
|
||||
// __semwait_signal
|
||||
// Proc_info
|
||||
// sendfile
|
||||
// Stat64_extended
|
||||
// Lstat64_extended
|
||||
// Fstat64_extended
|
||||
// __pthread_chdir
|
||||
// __pthread_fchdir
|
||||
// Audit
|
||||
// Auditon
|
||||
// Getauid
|
||||
// Setauid
|
||||
// Getaudit
|
||||
// Setaudit
|
||||
// Getaudit_addr
|
||||
// Setaudit_addr
|
||||
// Auditctl
|
||||
// Bsdthread_create
|
||||
// Bsdthread_terminate
|
||||
// Stack_snapshot
|
||||
// Bsdthread_register
|
||||
// Workq_open
|
||||
// Workq_ops
|
||||
// __mac_execve
|
||||
// __mac_syscall
|
||||
// __mac_get_file
|
||||
// __mac_set_file
|
||||
// __mac_get_link
|
||||
// __mac_set_link
|
||||
// __mac_get_proc
|
||||
// __mac_set_proc
|
||||
// __mac_get_fd
|
||||
// __mac_set_fd
|
||||
// __mac_get_pid
|
||||
// __mac_get_lcid
|
||||
// __mac_get_lctx
|
||||
// __mac_set_lctx
|
||||
// Setlcid
|
||||
// Read_nocancel
|
||||
// Write_nocancel
|
||||
// Open_nocancel
|
||||
// Close_nocancel
|
||||
// Wait4_nocancel
|
||||
// Recvmsg_nocancel
|
||||
// Sendmsg_nocancel
|
||||
// Recvfrom_nocancel
|
||||
// Accept_nocancel
|
||||
// Msync_nocancel
|
||||
// Fcntl_nocancel
|
||||
// Select_nocancel
|
||||
// Fsync_nocancel
|
||||
// Connect_nocancel
|
||||
// Sigsuspend_nocancel
|
||||
// Readv_nocancel
|
||||
// Writev_nocancel
|
||||
// Sendto_nocancel
|
||||
// Pread_nocancel
|
||||
// Pwrite_nocancel
|
||||
// Waitid_nocancel
|
||||
// Poll_nocancel
|
||||
// Msgsnd_nocancel
|
||||
// Msgrcv_nocancel
|
||||
// Sem_wait_nocancel
|
||||
// Aio_suspend_nocancel
|
||||
// __sigwait_nocancel
|
||||
// __semwait_signal_nocancel
|
||||
// __mac_mount
|
||||
// __mac_get_mount
|
||||
// __mac_getfsstat
|
77
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
77
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// 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.
|
||||
|
||||
// +build 386,darwin
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = int32(nsec / 1e9)
|
||||
ts.Nsec = int32(nsec % 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = int32(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
//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) {
|
||||
k.Ident = uint32(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint32(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var length = uint64(count)
|
||||
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
|
||||
|
||||
written = int(length)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||
|
||||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||
// of darwin/386 the syscall is called sysctl instead of __sysctl.
|
||||
const SYS___SYSCTL = SYS_SYSCTL
|
79
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
79
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
// 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.
|
||||
|
||||
// +build amd64,darwin
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = nsec / 1e9
|
||||
ts.Nsec = nsec % 1e9
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = int64(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
//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) {
|
||||
k.Ident = uint64(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint64(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var length = uint64(count)
|
||||
|
||||
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
|
||||
|
||||
written = int(length)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||
|
||||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||
// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
|
||||
const SYS___SYSCTL = SYS_SYSCTL
|
71
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
71
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright 2015 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 unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = int32(nsec / 1e9)
|
||||
ts.Nsec = int32(nsec % 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = int32(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
//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) {
|
||||
k.Ident = uint32(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint32(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var length = uint64(count)
|
||||
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
|
||||
|
||||
written = int(length)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
77
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
77
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright 2015 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 arm64,darwin
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 16384 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = nsec / 1e9
|
||||
ts.Nsec = nsec % 1e9
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = int64(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
//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) {
|
||||
k.Ident = uint64(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint64(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var length = uint64(count)
|
||||
|
||||
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
|
||||
|
||||
written = int(length)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
||||
|
||||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||
// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
|
||||
const SYS___SYSCTL = SYS_SYSCTL
|
412
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
Normal file
412
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
Normal file
@ -0,0 +1,412 @@
|
||||
// Copyright 2009,2010 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.
|
||||
|
||||
// FreeBSD system calls.
|
||||
// This file is compiled as ordinary Go code,
|
||||
// but it is also input to mksyscall,
|
||||
// which parses the //sys lines and generates system call stubs.
|
||||
// Note that sometimes we use a lowercase //sys name and wrap
|
||||
// it in our own nicer implementation, either here or in
|
||||
// syscall_bsd.go or syscall_unix.go.
|
||||
|
||||
package unix
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type SockaddrDatalink struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Index uint16
|
||||
Type uint8
|
||||
Nlen uint8
|
||||
Alen uint8
|
||||
Slen uint8
|
||||
Data [12]int8
|
||||
Rcf uint16
|
||||
Route [16]uint16
|
||||
raw RawSockaddrDatalink
|
||||
}
|
||||
|
||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||
func nametomib(name string) (mib []_C_int, err error) {
|
||||
const siz = unsafe.Sizeof(mib[0])
|
||||
|
||||
// NOTE(rsc): It seems strange to set the buffer to have
|
||||
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||
// as the size. I don't know why the +2 is here, but the
|
||||
// kernel uses +2 for its own implementation of this function.
|
||||
// I am scared that if we don't include the +2 here, the kernel
|
||||
// will silently write 2 words farther than we specify
|
||||
// and we'll get memory corruption.
|
||||
var buf [CTL_MAXNAME + 2]_C_int
|
||||
n := uintptr(CTL_MAXNAME) * siz
|
||||
|
||||
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||
bytes, err := ByteSliceFromString(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Magic sysctl: "setting" 0.3 to a string name
|
||||
// lets you read back the array of integers form.
|
||||
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf[0 : n/siz], nil
|
||||
}
|
||||
|
||||
// ParseDirent parses up to max directory entries in buf,
|
||||
// appending the names to names. It returns the number
|
||||
// bytes consumed from buf, the number of entries added
|
||||
// to names, and the new names slice.
|
||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||
origlen := len(buf)
|
||||
for max != 0 && len(buf) > 0 {
|
||||
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||
reclen := int(16+dirent.Namlen+1+7) & ^7
|
||||
buf = buf[reclen:]
|
||||
if dirent.Fileno == 0 { // File absent in directory.
|
||||
continue
|
||||
}
|
||||
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||
var name = string(bytes[0:dirent.Namlen])
|
||||
if name == "." || name == ".." { // Useless names
|
||||
continue
|
||||
}
|
||||
max--
|
||||
count++
|
||||
names = append(names, name)
|
||||
}
|
||||
return origlen - len(buf), count, names
|
||||
}
|
||||
|
||||
//sysnb pipe() (r int, w int, err error)
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
p[0], p[1], err = pipe()
|
||||
return
|
||||
}
|
||||
|
||||
//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||
return extpread(fd, p, 0, offset)
|
||||
}
|
||||
|
||||
//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
||||
return extpwrite(fd, p, 0, offset)
|
||||
}
|
||||
|
||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
var bufsize uintptr
|
||||
if len(buf) > 0 {
|
||||
_p0 = unsafe.Pointer(&buf[0])
|
||||
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||
}
|
||||
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||
use(unsafe.Pointer(_p0))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed directly
|
||||
*/
|
||||
//sys Access(path string, mode uint32) (err error)
|
||||
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||
//sys Chdir(path string) (err error)
|
||||
//sys Chflags(path string, flags int) (err error)
|
||||
//sys Chmod(path string, mode uint32) (err error)
|
||||
//sys Chown(path string, uid int, gid int) (err error)
|
||||
//sys Chroot(path string) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys Dup(fd int) (nfd int, err error)
|
||||
//sys Dup2(from int, to int) (err error)
|
||||
//sys Exit(code int)
|
||||
//sys Fchdir(fd int) (err error)
|
||||
//sys Fchflags(fd int, flags int) (err error)
|
||||
//sys Fchmod(fd int, mode uint32) (err error)
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Flock(fd int, how int) (err error)
|
||||
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||
//sys Fsync(fd int) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
|
||||
//sys Getdtablesize() (size int)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (uid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||
//sysnb Getpgrp() (pgrp int)
|
||||
//sysnb Getpid() (pid int)
|
||||
//sysnb Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (prio int, err error)
|
||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getsid(pid int) (sid int, err error)
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Issetugid() (tainted bool)
|
||||
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||
//sys Kqueue() (fd int, err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Link(path string, link string) (err error)
|
||||
//sys Listen(s int, backlog int) (err error)
|
||||
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||
//sys Mkdir(path string, mode uint32) (err error)
|
||||
//sys Mkfifo(path string, mode uint32) (err error)
|
||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||
//sys Mlock(b []byte) (err error)
|
||||
//sys Mlockall(flags int) (err error)
|
||||
//sys Mprotect(b []byte, prot int) (err error)
|
||||
//sys Munlock(b []byte) (err error)
|
||||
//sys Munlockall() (err error)
|
||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||
//sys Pathconf(path string, name int) (val int, err error)
|
||||
//sys read(fd int, p []byte) (n int, err error)
|
||||
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||
//sys Rename(from string, to string) (err error)
|
||||
//sys Revoke(path string) (err error)
|
||||
//sys Rmdir(path string) (err error)
|
||||
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||
//sysnb Setegid(egid int) (err error)
|
||||
//sysnb Seteuid(euid int) (err error)
|
||||
//sysnb Setgid(gid int) (err error)
|
||||
//sys Setlogin(name string) (err error)
|
||||
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||
//sys Setpriority(which int, who int, prio int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Setsid() (pid int, err error)
|
||||
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||
//sysnb Setuid(uid int) (err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error)
|
||||
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||
//sys Symlink(path string, link string) (err error)
|
||||
//sys Sync() (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
//sys Umask(newmask int) (oldmask int)
|
||||
//sys Undelete(path string) (err error)
|
||||
//sys Unlink(path string) (err error)
|
||||
//sys Unmount(path string, flags int) (err error)
|
||||
//sys write(fd int, p []byte) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
* TODO(jsing): Update this list for DragonFly.
|
||||
*/
|
||||
// Profil
|
||||
// Sigaction
|
||||
// Sigprocmask
|
||||
// Getlogin
|
||||
// Sigpending
|
||||
// Sigaltstack
|
||||
// Ioctl
|
||||
// Reboot
|
||||
// Execve
|
||||
// Vfork
|
||||
// Sbrk
|
||||
// Sstk
|
||||
// Ovadvise
|
||||
// Mincore
|
||||
// Setitimer
|
||||
// Swapon
|
||||
// Select
|
||||
// Sigsuspend
|
||||
// Readv
|
||||
// Writev
|
||||
// Nfssvc
|
||||
// Getfh
|
||||
// Quotactl
|
||||
// Mount
|
||||
// Csops
|
||||
// Waitid
|
||||
// Add_profil
|
||||
// Kdebug_trace
|
||||
// Sigreturn
|
||||
// Mmap
|
||||
// Atsocket
|
||||
// Kqueue_from_portset_np
|
||||
// Kqueue_portset
|
||||
// Getattrlist
|
||||
// Setattrlist
|
||||
// Getdirentriesattr
|
||||
// Searchfs
|
||||
// Delete
|
||||
// Copyfile
|
||||
// Poll
|
||||
// Watchevent
|
||||
// Waitevent
|
||||
// Modwatch
|
||||
// Getxattr
|
||||
// Fgetxattr
|
||||
// Setxattr
|
||||
// Fsetxattr
|
||||
// Removexattr
|
||||
// Fremovexattr
|
||||
// Listxattr
|
||||
// Flistxattr
|
||||
// Fsctl
|
||||
// Initgroups
|
||||
// Posix_spawn
|
||||
// Nfsclnt
|
||||
// Fhopen
|
||||
// Minherit
|
||||
// Semsys
|
||||
// Msgsys
|
||||
// Shmsys
|
||||
// Semctl
|
||||
// Semget
|
||||
// Semop
|
||||
// Msgctl
|
||||
// Msgget
|
||||
// Msgsnd
|
||||
// Msgrcv
|
||||
// Shmat
|
||||
// Shmctl
|
||||
// Shmdt
|
||||
// Shmget
|
||||
// Shm_open
|
||||
// Shm_unlink
|
||||
// Sem_open
|
||||
// Sem_close
|
||||
// Sem_unlink
|
||||
// Sem_wait
|
||||
// Sem_trywait
|
||||
// Sem_post
|
||||
// Sem_getvalue
|
||||
// Sem_init
|
||||
// Sem_destroy
|
||||
// Open_extended
|
||||
// Umask_extended
|
||||
// Stat_extended
|
||||
// Lstat_extended
|
||||
// Fstat_extended
|
||||
// Chmod_extended
|
||||
// Fchmod_extended
|
||||
// Access_extended
|
||||
// Settid
|
||||
// Gettid
|
||||
// Setsgroups
|
||||
// Getsgroups
|
||||
// Setwgroups
|
||||
// Getwgroups
|
||||
// Mkfifo_extended
|
||||
// Mkdir_extended
|
||||
// Identitysvc
|
||||
// Shared_region_check_np
|
||||
// Shared_region_map_np
|
||||
// __pthread_mutex_destroy
|
||||
// __pthread_mutex_init
|
||||
// __pthread_mutex_lock
|
||||
// __pthread_mutex_trylock
|
||||
// __pthread_mutex_unlock
|
||||
// __pthread_cond_init
|
||||
// __pthread_cond_destroy
|
||||
// __pthread_cond_broadcast
|
||||
// __pthread_cond_signal
|
||||
// Setsid_with_pid
|
||||
// __pthread_cond_timedwait
|
||||
// Aio_fsync
|
||||
// Aio_return
|
||||
// Aio_suspend
|
||||
// Aio_cancel
|
||||
// Aio_error
|
||||
// Aio_read
|
||||
// Aio_write
|
||||
// Lio_listio
|
||||
// __pthread_cond_wait
|
||||
// Iopolicysys
|
||||
// __pthread_kill
|
||||
// __pthread_sigmask
|
||||
// __sigwait
|
||||
// __disable_threadsignal
|
||||
// __pthread_markcancel
|
||||
// __pthread_canceled
|
||||
// __semwait_signal
|
||||
// Proc_info
|
||||
// Stat64_extended
|
||||
// Lstat64_extended
|
||||
// Fstat64_extended
|
||||
// __pthread_chdir
|
||||
// __pthread_fchdir
|
||||
// Audit
|
||||
// Auditon
|
||||
// Getauid
|
||||
// Setauid
|
||||
// Getaudit
|
||||
// Setaudit
|
||||
// Getaudit_addr
|
||||
// Setaudit_addr
|
||||
// Auditctl
|
||||
// Bsdthread_create
|
||||
// Bsdthread_terminate
|
||||
// Stack_snapshot
|
||||
// Bsdthread_register
|
||||
// Workq_open
|
||||
// Workq_ops
|
||||
// __mac_execve
|
||||
// __mac_syscall
|
||||
// __mac_get_file
|
||||
// __mac_set_file
|
||||
// __mac_get_link
|
||||
// __mac_set_link
|
||||
// __mac_get_proc
|
||||
// __mac_set_proc
|
||||
// __mac_get_fd
|
||||
// __mac_set_fd
|
||||
// __mac_get_pid
|
||||
// __mac_get_lcid
|
||||
// __mac_get_lctx
|
||||
// __mac_set_lctx
|
||||
// Setlcid
|
||||
// Read_nocancel
|
||||
// Write_nocancel
|
||||
// Open_nocancel
|
||||
// Close_nocancel
|
||||
// Wait4_nocancel
|
||||
// Recvmsg_nocancel
|
||||
// Sendmsg_nocancel
|
||||
// Recvfrom_nocancel
|
||||
// Accept_nocancel
|
||||
// Msync_nocancel
|
||||
// Fcntl_nocancel
|
||||
// Select_nocancel
|
||||
// Fsync_nocancel
|
||||
// Connect_nocancel
|
||||
// Sigsuspend_nocancel
|
||||
// Readv_nocancel
|
||||
// Writev_nocancel
|
||||
// Sendto_nocancel
|
||||
// Pread_nocancel
|
||||
// Pwrite_nocancel
|
||||
// Waitid_nocancel
|
||||
// Poll_nocancel
|
||||
// Msgsnd_nocancel
|
||||
// Msgrcv_nocancel
|
||||
// Sem_wait_nocancel
|
||||
// Aio_suspend_nocancel
|
||||
// __sigwait_nocancel
|
||||
// __semwait_signal_nocancel
|
||||
// __mac_mount
|
||||
// __mac_get_mount
|
||||
// __mac_getfsstat
|
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
// +build amd64,dragonfly
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = nsec / 1e9
|
||||
ts.Nsec = nsec % 1e9
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = nsec % 1e9 / 1e3
|
||||
tv.Sec = int64(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||
k.Ident = uint64(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint64(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var writtenOut uint64 = 0
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
|
||||
|
||||
written = int(writtenOut)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
683
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
Normal file
683
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,683 @@
|
||||
// Copyright 2009,2010 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.
|
||||
|
||||
// FreeBSD system calls.
|
||||
// This file is compiled as ordinary Go code,
|
||||
// but it is also input to mksyscall,
|
||||
// which parses the //sys lines and generates system call stubs.
|
||||
// Note that sometimes we use a lowercase //sys name and wrap
|
||||
// it in our own nicer implementation, either here or in
|
||||
// syscall_bsd.go or syscall_unix.go.
|
||||
|
||||
package unix
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type SockaddrDatalink struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Index uint16
|
||||
Type uint8
|
||||
Nlen uint8
|
||||
Alen uint8
|
||||
Slen uint8
|
||||
Data [46]int8
|
||||
raw RawSockaddrDatalink
|
||||
}
|
||||
|
||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||
func nametomib(name string) (mib []_C_int, err error) {
|
||||
const siz = unsafe.Sizeof(mib[0])
|
||||
|
||||
// NOTE(rsc): It seems strange to set the buffer to have
|
||||
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||
// as the size. I don't know why the +2 is here, but the
|
||||
// kernel uses +2 for its own implementation of this function.
|
||||
// I am scared that if we don't include the +2 here, the kernel
|
||||
// will silently write 2 words farther than we specify
|
||||
// and we'll get memory corruption.
|
||||
var buf [CTL_MAXNAME + 2]_C_int
|
||||
n := uintptr(CTL_MAXNAME) * siz
|
||||
|
||||
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||
bytes, err := ByteSliceFromString(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Magic sysctl: "setting" 0.3 to a string name
|
||||
// lets you read back the array of integers form.
|
||||
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf[0 : n/siz], nil
|
||||
}
|
||||
|
||||
// ParseDirent parses up to max directory entries in buf,
|
||||
// appending the names to names. It returns the number
|
||||
// bytes consumed from buf, the number of entries added
|
||||
// to names, and the new names slice.
|
||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||
origlen := len(buf)
|
||||
for max != 0 && len(buf) > 0 {
|
||||
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||
if dirent.Reclen == 0 {
|
||||
buf = nil
|
||||
break
|
||||
}
|
||||
buf = buf[dirent.Reclen:]
|
||||
if dirent.Fileno == 0 { // File absent in directory.
|
||||
continue
|
||||
}
|
||||
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||
var name = string(bytes[0:dirent.Namlen])
|
||||
if name == "." || name == ".." { // Useless names
|
||||
continue
|
||||
}
|
||||
max--
|
||||
count++
|
||||
names = append(names, name)
|
||||
}
|
||||
return origlen - len(buf), count, names
|
||||
}
|
||||
|
||||
//sysnb pipe() (r int, w int, err error)
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
p[0], p[1], err = pipe()
|
||||
return
|
||||
}
|
||||
|
||||
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||
var value IPMreqn
|
||||
vallen := _Socklen(SizeofIPMreqn)
|
||||
errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, errno
|
||||
}
|
||||
|
||||
func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
|
||||
}
|
||||
|
||||
func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
|
||||
var rsa RawSockaddrAny
|
||||
var len _Socklen = SizeofSockaddrAny
|
||||
nfd, err = accept4(fd, &rsa, &len, flags)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len > SizeofSockaddrAny {
|
||||
panic("RawSockaddrAny too small")
|
||||
}
|
||||
sa, err = anyToSockaddr(&rsa)
|
||||
if err != nil {
|
||||
Close(nfd)
|
||||
nfd = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
var bufsize uintptr
|
||||
if len(buf) > 0 {
|
||||
_p0 = unsafe.Pointer(&buf[0])
|
||||
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||
}
|
||||
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||
use(unsafe.Pointer(_p0))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Derive extattr namespace and attribute name
|
||||
|
||||
func xattrnamespace(fullattr string) (ns int, attr string, err error) {
|
||||
s := -1
|
||||
for idx, val := range fullattr {
|
||||
if val == '.' {
|
||||
s = idx
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if s == -1 {
|
||||
return -1, "", ENOATTR
|
||||
}
|
||||
|
||||
namespace := fullattr[0:s]
|
||||
attr = fullattr[s+1:]
|
||||
|
||||
switch namespace {
|
||||
case "user":
|
||||
return EXTATTR_NAMESPACE_USER, attr, nil
|
||||
case "system":
|
||||
return EXTATTR_NAMESPACE_SYSTEM, attr, nil
|
||||
default:
|
||||
return -1, "", ENOATTR
|
||||
}
|
||||
}
|
||||
|
||||
func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
|
||||
if len(dest) > idx {
|
||||
return unsafe.Pointer(&dest[idx])
|
||||
} else {
|
||||
return unsafe.Pointer(_zero)
|
||||
}
|
||||
}
|
||||
|
||||
// FreeBSD implements its own syscalls to handle extended attributes
|
||||
|
||||
func Getxattr(file string, attr string, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsize := len(dest)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return ExtattrGetFile(file, nsid, a, uintptr(d), destsize)
|
||||
}
|
||||
|
||||
func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsize := len(dest)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize)
|
||||
}
|
||||
|
||||
func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsize := len(dest)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return ExtattrGetLink(link, nsid, a, uintptr(d), destsize)
|
||||
}
|
||||
|
||||
// flags are unused on FreeBSD
|
||||
|
||||
func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
|
||||
d := unsafe.Pointer(&data[0])
|
||||
datasiz := len(data)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz)
|
||||
return
|
||||
}
|
||||
|
||||
func Setxattr(file string, attr string, data []byte, flags int) (err error) {
|
||||
d := unsafe.Pointer(&data[0])
|
||||
datasiz := len(data)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz)
|
||||
return
|
||||
}
|
||||
|
||||
func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
|
||||
d := unsafe.Pointer(&data[0])
|
||||
datasiz := len(data)
|
||||
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz)
|
||||
return
|
||||
}
|
||||
|
||||
func Removexattr(file string, attr string) (err error) {
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = ExtattrDeleteFile(file, nsid, a)
|
||||
return
|
||||
}
|
||||
|
||||
func Fremovexattr(fd int, attr string) (err error) {
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = ExtattrDeleteFd(fd, nsid, a)
|
||||
return
|
||||
}
|
||||
|
||||
func Lremovexattr(link string, attr string) (err error) {
|
||||
nsid, a, err := xattrnamespace(attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = ExtattrDeleteLink(link, nsid, a)
|
||||
return
|
||||
}
|
||||
|
||||
func Listxattr(file string, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsiz := len(dest)
|
||||
|
||||
// FreeBSD won't allow you to list xattrs from multiple namespaces
|
||||
s := 0
|
||||
var e error
|
||||
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||
stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
|
||||
|
||||
/* Errors accessing system attrs are ignored so that
|
||||
* we can implement the Linux-like behavior of omitting errors that
|
||||
* we don't have read permissions on
|
||||
*
|
||||
* Linux will still error if we ask for user attributes on a file that
|
||||
* we don't have read permissions on, so don't ignore those errors
|
||||
*/
|
||||
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||
e = nil
|
||||
continue
|
||||
} else if e != nil {
|
||||
return s, e
|
||||
}
|
||||
|
||||
s += stmp
|
||||
destsiz -= s
|
||||
if destsiz < 0 {
|
||||
destsiz = 0
|
||||
}
|
||||
d = initxattrdest(dest, s)
|
||||
}
|
||||
|
||||
return s, e
|
||||
}
|
||||
|
||||
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsiz := len(dest)
|
||||
|
||||
s := 0
|
||||
var e error
|
||||
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||
stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
|
||||
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||
e = nil
|
||||
continue
|
||||
} else if e != nil {
|
||||
return s, e
|
||||
}
|
||||
|
||||
s += stmp
|
||||
destsiz -= s
|
||||
if destsiz < 0 {
|
||||
destsiz = 0
|
||||
}
|
||||
d = initxattrdest(dest, s)
|
||||
}
|
||||
|
||||
return s, e
|
||||
}
|
||||
|
||||
func Llistxattr(link string, dest []byte) (sz int, err error) {
|
||||
d := initxattrdest(dest, 0)
|
||||
destsiz := len(dest)
|
||||
|
||||
s := 0
|
||||
var e error
|
||||
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||
stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
|
||||
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||
e = nil
|
||||
continue
|
||||
} else if e != nil {
|
||||
return s, e
|
||||
}
|
||||
|
||||
s += stmp
|
||||
destsiz -= s
|
||||
if destsiz < 0 {
|
||||
destsiz = 0
|
||||
}
|
||||
d = initxattrdest(dest, s)
|
||||
}
|
||||
|
||||
return s, e
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed directly
|
||||
*/
|
||||
//sys Access(path string, mode uint32) (err error)
|
||||
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||
//sys Chdir(path string) (err error)
|
||||
//sys Chflags(path string, flags int) (err error)
|
||||
//sys Chmod(path string, mode uint32) (err error)
|
||||
//sys Chown(path string, uid int, gid int) (err error)
|
||||
//sys Chroot(path string) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys Dup(fd int) (nfd int, err error)
|
||||
//sys Dup2(from int, to int) (err error)
|
||||
//sys Exit(code int)
|
||||
//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
|
||||
//sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
|
||||
//sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
|
||||
//sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
|
||||
//sys Fchdir(fd int) (err error)
|
||||
//sys Fchflags(fd int, flags int) (err error)
|
||||
//sys Fchmod(fd int, mode uint32) (err error)
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Flock(fd int, how int) (err error)
|
||||
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||
//sys Fsync(fd int) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
|
||||
//sys Getdtablesize() (size int)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (uid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||
//sysnb Getpgrp() (pgrp int)
|
||||
//sysnb Getpid() (pid int)
|
||||
//sysnb Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (prio int, err error)
|
||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getsid(pid int) (sid int, err error)
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Issetugid() (tainted bool)
|
||||
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||
//sys Kqueue() (fd int, err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Link(path string, link string) (err error)
|
||||
//sys Listen(s int, backlog int) (err error)
|
||||
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||
//sys Mkdir(path string, mode uint32) (err error)
|
||||
//sys Mkfifo(path string, mode uint32) (err error)
|
||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||
//sys Mlock(b []byte) (err error)
|
||||
//sys Mlockall(flags int) (err error)
|
||||
//sys Mprotect(b []byte, prot int) (err error)
|
||||
//sys Munlock(b []byte) (err error)
|
||||
//sys Munlockall() (err error)
|
||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||
//sys Pathconf(path string, name int) (val int, err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||
//sys read(fd int, p []byte) (n int, err error)
|
||||
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||
//sys Rename(from string, to string) (err error)
|
||||
//sys Revoke(path string) (err error)
|
||||
//sys Rmdir(path string) (err error)
|
||||
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||
//sysnb Setegid(egid int) (err error)
|
||||
//sysnb Seteuid(euid int) (err error)
|
||||
//sysnb Setgid(gid int) (err error)
|
||||
//sys Setlogin(name string) (err error)
|
||||
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||
//sys Setpriority(which int, who int, prio int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Setsid() (pid int, err error)
|
||||
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||
//sysnb Setuid(uid int) (err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error)
|
||||
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||
//sys Symlink(path string, link string) (err error)
|
||||
//sys Sync() (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
//sys Umask(newmask int) (oldmask int)
|
||||
//sys Undelete(path string) (err error)
|
||||
//sys Unlink(path string) (err error)
|
||||
//sys Unmount(path string, flags int) (err error)
|
||||
//sys write(fd int, p []byte) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||
//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
*/
|
||||
// Profil
|
||||
// Sigaction
|
||||
// Sigprocmask
|
||||
// Getlogin
|
||||
// Sigpending
|
||||
// Sigaltstack
|
||||
// Ioctl
|
||||
// Reboot
|
||||
// Execve
|
||||
// Vfork
|
||||
// Sbrk
|
||||
// Sstk
|
||||
// Ovadvise
|
||||
// Mincore
|
||||
// Setitimer
|
||||
// Swapon
|
||||
// Select
|
||||
// Sigsuspend
|
||||
// Readv
|
||||
// Writev
|
||||
// Nfssvc
|
||||
// Getfh
|
||||
// Quotactl
|
||||
// Mount
|
||||
// Csops
|
||||
// Waitid
|
||||
// Add_profil
|
||||
// Kdebug_trace
|
||||
// Sigreturn
|
||||
// Mmap
|
||||
// Mlock
|
||||
// Munlock
|
||||
// Atsocket
|
||||
// Kqueue_from_portset_np
|
||||
// Kqueue_portset
|
||||
// Getattrlist
|
||||
// Setattrlist
|
||||
// Getdirentriesattr
|
||||
// Searchfs
|
||||
// Delete
|
||||
// Copyfile
|
||||
// Poll
|
||||
// Watchevent
|
||||
// Waitevent
|
||||
// Modwatch
|
||||
// Getxattr
|
||||
// Fgetxattr
|
||||
// Setxattr
|
||||
// Fsetxattr
|
||||
// Removexattr
|
||||
// Fremovexattr
|
||||
// Listxattr
|
||||
// Flistxattr
|
||||
// Fsctl
|
||||
// Initgroups
|
||||
// Posix_spawn
|
||||
// Nfsclnt
|
||||
// Fhopen
|
||||
// Minherit
|
||||
// Semsys
|
||||
// Msgsys
|
||||
// Shmsys
|
||||
// Semctl
|
||||
// Semget
|
||||
// Semop
|
||||
// Msgctl
|
||||
// Msgget
|
||||
// Msgsnd
|
||||
// Msgrcv
|
||||
// Shmat
|
||||
// Shmctl
|
||||
// Shmdt
|
||||
// Shmget
|
||||
// Shm_open
|
||||
// Shm_unlink
|
||||
// Sem_open
|
||||
// Sem_close
|
||||
// Sem_unlink
|
||||
// Sem_wait
|
||||
// Sem_trywait
|
||||
// Sem_post
|
||||
// Sem_getvalue
|
||||
// Sem_init
|
||||
// Sem_destroy
|
||||
// Open_extended
|
||||
// Umask_extended
|
||||
// Stat_extended
|
||||
// Lstat_extended
|
||||
// Fstat_extended
|
||||
// Chmod_extended
|
||||
// Fchmod_extended
|
||||
// Access_extended
|
||||
// Settid
|
||||
// Gettid
|
||||
// Setsgroups
|
||||
// Getsgroups
|
||||
// Setwgroups
|
||||
// Getwgroups
|
||||
// Mkfifo_extended
|
||||
// Mkdir_extended
|
||||
// Identitysvc
|
||||
// Shared_region_check_np
|
||||
// Shared_region_map_np
|
||||
// __pthread_mutex_destroy
|
||||
// __pthread_mutex_init
|
||||
// __pthread_mutex_lock
|
||||
// __pthread_mutex_trylock
|
||||
// __pthread_mutex_unlock
|
||||
// __pthread_cond_init
|
||||
// __pthread_cond_destroy
|
||||
// __pthread_cond_broadcast
|
||||
// __pthread_cond_signal
|
||||
// Setsid_with_pid
|
||||
// __pthread_cond_timedwait
|
||||
// Aio_fsync
|
||||
// Aio_return
|
||||
// Aio_suspend
|
||||
// Aio_cancel
|
||||
// Aio_error
|
||||
// Aio_read
|
||||
// Aio_write
|
||||
// Lio_listio
|
||||
// __pthread_cond_wait
|
||||
// Iopolicysys
|
||||
// Mlockall
|
||||
// Munlockall
|
||||
// __pthread_kill
|
||||
// __pthread_sigmask
|
||||
// __sigwait
|
||||
// __disable_threadsignal
|
||||
// __pthread_markcancel
|
||||
// __pthread_canceled
|
||||
// __semwait_signal
|
||||
// Proc_info
|
||||
// Stat64_extended
|
||||
// Lstat64_extended
|
||||
// Fstat64_extended
|
||||
// __pthread_chdir
|
||||
// __pthread_fchdir
|
||||
// Audit
|
||||
// Auditon
|
||||
// Getauid
|
||||
// Setauid
|
||||
// Getaudit
|
||||
// Setaudit
|
||||
// Getaudit_addr
|
||||
// Setaudit_addr
|
||||
// Auditctl
|
||||
// Bsdthread_create
|
||||
// Bsdthread_terminate
|
||||
// Stack_snapshot
|
||||
// Bsdthread_register
|
||||
// Workq_open
|
||||
// Workq_ops
|
||||
// __mac_execve
|
||||
// __mac_syscall
|
||||
// __mac_get_file
|
||||
// __mac_set_file
|
||||
// __mac_get_link
|
||||
// __mac_set_link
|
||||
// __mac_get_proc
|
||||
// __mac_set_proc
|
||||
// __mac_get_fd
|
||||
// __mac_set_fd
|
||||
// __mac_get_pid
|
||||
// __mac_get_lcid
|
||||
// __mac_get_lctx
|
||||
// __mac_set_lctx
|
||||
// Setlcid
|
||||
// Read_nocancel
|
||||
// Write_nocancel
|
||||
// Open_nocancel
|
||||
// Close_nocancel
|
||||
// Wait4_nocancel
|
||||
// Recvmsg_nocancel
|
||||
// Sendmsg_nocancel
|
||||
// Recvfrom_nocancel
|
||||
// Accept_nocancel
|
||||
// Msync_nocancel
|
||||
// Fcntl_nocancel
|
||||
// Select_nocancel
|
||||
// Fsync_nocancel
|
||||
// Connect_nocancel
|
||||
// Sigsuspend_nocancel
|
||||
// Readv_nocancel
|
||||
// Writev_nocancel
|
||||
// Sendto_nocancel
|
||||
// Pread_nocancel
|
||||
// Pwrite_nocancel
|
||||
// Waitid_nocancel
|
||||
// Poll_nocancel
|
||||
// Msgsnd_nocancel
|
||||
// Msgrcv_nocancel
|
||||
// Sem_wait_nocancel
|
||||
// Aio_suspend_nocancel
|
||||
// __sigwait_nocancel
|
||||
// __semwait_signal_nocancel
|
||||
// __mac_mount
|
||||
// __mac_get_mount
|
||||
// __mac_getfsstat
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_386.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_386.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
// +build 386,freebsd
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = int32(nsec / 1e9)
|
||||
ts.Nsec = int32(nsec % 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = int32(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||
k.Ident = uint32(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint32(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var writtenOut uint64 = 0
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||
|
||||
written = int(writtenOut)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
// +build amd64,freebsd
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = nsec / 1e9
|
||||
ts.Nsec = nsec % 1e9
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = nsec % 1e9 / 1e3
|
||||
tv.Sec = int64(nsec / 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||
k.Ident = uint64(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint64(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var writtenOut uint64 = 0
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
|
||||
|
||||
written = int(writtenOut)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright 2012 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 arm,freebsd
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = nsec / 1e9
|
||||
ts.Nsec = int32(nsec % 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
tv.Sec = nsec / 1e9
|
||||
return
|
||||
}
|
||||
|
||||
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||
k.Ident = uint32(fd)
|
||||
k.Filter = int16(mode)
|
||||
k.Flags = uint16(flags)
|
||||
}
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint32(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
var writtenOut uint64 = 0
|
||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||
|
||||
written = int(writtenOut)
|
||||
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
1115
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
Normal file
1115
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
399
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
Normal file
399
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
Normal file
@ -0,0 +1,399 @@
|
||||
// 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.
|
||||
|
||||
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
|
||||
// so that go vet can check that they are correct.
|
||||
|
||||
// +build 386,linux
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Getpagesize() int { return 4096 }
|
||||
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
|
||||
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||
ts.Sec = int32(nsec / 1e9)
|
||||
ts.Nsec = int32(nsec % 1e9)
|
||||
return
|
||||
}
|
||||
|
||||
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||
nsec += 999 // round up to microsecond
|
||||
tv.Sec = int32(nsec / 1e9)
|
||||
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||
return
|
||||
}
|
||||
|
||||
//sysnb pipe(p *[2]_C_int) (err error)
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
var pp [2]_C_int
|
||||
err = pipe(&pp)
|
||||
p[0] = int(pp[0])
|
||||
p[1] = int(pp[1])
|
||||
return
|
||||
}
|
||||
|
||||
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
var pp [2]_C_int
|
||||
err = pipe2(&pp, flags)
|
||||
p[0] = int(pp[0])
|
||||
p[1] = int(pp[1])
|
||||
return
|
||||
}
|
||||
|
||||
// 64-bit file system and 32-bit uid calls
|
||||
// (386 default is 32-bit file system and 16-bit uid).
|
||||
//sys Dup2(oldfd int, newfd int) (err error)
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64
|
||||
//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
|
||||
//sysnb Getegid() (egid int) = SYS_GETEGID32
|
||||
//sysnb Geteuid() (euid int) = SYS_GETEUID32
|
||||
//sysnb Getgid() (gid int) = SYS_GETGID32
|
||||
//sysnb Getuid() (uid int) = SYS_GETUID32
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
//sys Ioperm(from int, num int, on int) (err error)
|
||||
//sys Iopl(level int) (err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
|
||||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||
//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
|
||||
//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32
|
||||
//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
|
||||
//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
|
||||
//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
|
||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||
|
||||
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||
//sys Pause() (err error)
|
||||
|
||||
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
|
||||
page := uintptr(offset / 4096)
|
||||
if offset != int64(page)*4096 {
|
||||
return 0, EINVAL
|
||||
}
|
||||
return mmap2(addr, length, prot, flags, fd, page)
|
||||
}
|
||||
|
||||
type rlimit32 struct {
|
||||
Cur uint32
|
||||
Max uint32
|
||||
}
|
||||
|
||||
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
|
||||
|
||||
const rlimInf32 = ^uint32(0)
|
||||
const rlimInf64 = ^uint64(0)
|
||||
|
||||
func Getrlimit(resource int, rlim *Rlimit) (err error) {
|
||||
err = prlimit(0, resource, nil, rlim)
|
||||
if err != ENOSYS {
|
||||
return err
|
||||
}
|
||||
|
||||
rl := rlimit32{}
|
||||
err = getrlimit(resource, &rl)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if rl.Cur == rlimInf32 {
|
||||
rlim.Cur = rlimInf64
|
||||
} else {
|
||||
rlim.Cur = uint64(rl.Cur)
|
||||
}
|
||||
|
||||
if rl.Max == rlimInf32 {
|
||||
rlim.Max = rlimInf64
|
||||
} else {
|
||||
rlim.Max = uint64(rl.Max)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
|
||||
|
||||
func Setrlimit(resource int, rlim *Rlimit) (err error) {
|
||||
err = prlimit(0, resource, rlim, nil)
|
||||
if err != ENOSYS {
|
||||
return err
|
||||
}
|
||||
|
||||
rl := rlimit32{}
|
||||
if rlim.Cur == rlimInf64 {
|
||||
rl.Cur = rlimInf32
|
||||
} else if rlim.Cur < uint64(rlimInf32) {
|
||||
rl.Cur = uint32(rlim.Cur)
|
||||
} else {
|
||||
return EINVAL
|
||||
}
|
||||
if rlim.Max == rlimInf64 {
|
||||
rl.Max = rlimInf32
|
||||
} else if rlim.Max < uint64(rlimInf32) {
|
||||
rl.Max = uint32(rlim.Max)
|
||||
} else {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
return setrlimit(resource, &rl)
|
||||
}
|
||||
|
||||
// Underlying system call writes to newoffset via pointer.
|
||||
// Implemented in assembly to avoid allocation.
|
||||
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
|
||||
|
||||
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||
newoffset, errno := seek(fd, offset, whence)
|
||||
if errno != 0 {
|
||||
return 0, errno
|
||||
}
|
||||
return newoffset, nil
|
||||
}
|
||||
|
||||
// Vsyscalls on amd64.
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||
|
||||
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||
|
||||
// On x86 Linux, all the socket calls go through an extra indirection,
|
||||
// I think because the 5-register system call interface can't handle
|
||||
// the 6-argument calls like sendto and recvfrom. Instead the
|
||||
// arguments to the underlying system call are the number below
|
||||
// and a pointer to an array of uintptr. We hide the pointer in the
|
||||
// socketcall assembly to avoid allocation on every system call.
|
||||
|
||||
const (
|
||||
// see linux/net.h
|
||||
_SOCKET = 1
|
||||
_BIND = 2
|
||||
_CONNECT = 3
|
||||
_LISTEN = 4
|
||||
_ACCEPT = 5
|
||||
_GETSOCKNAME = 6
|
||||
_GETPEERNAME = 7
|
||||
_SOCKETPAIR = 8
|
||||
_SEND = 9
|
||||
_RECV = 10
|
||||
_SENDTO = 11
|
||||
_RECVFROM = 12
|
||||
_SHUTDOWN = 13
|
||||
_SETSOCKOPT = 14
|
||||
_GETSOCKOPT = 15
|
||||
_SENDMSG = 16
|
||||
_RECVMSG = 17
|
||||
_ACCEPT4 = 18
|
||||
_RECVMMSG = 19
|
||||
_SENDMMSG = 20
|
||||
)
|
||||
|
||||
func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
|
||||
func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
|
||||
|
||||
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
|
||||
fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
|
||||
fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||
_, e := rawsocketcall(_GETSOCKNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||
_, e := rawsocketcall(_GETPEERNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
|
||||
_, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||
_, e := socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||
_, e := socketcall(_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func socket(domain int, typ int, proto int) (fd int, err error) {
|
||||
fd, e := rawsocketcall(_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
|
||||
_, e := socketcall(_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
|
||||
_, e := socketcall(_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
|
||||
var base uintptr
|
||||
if len(p) > 0 {
|
||||
base = uintptr(unsafe.Pointer(&p[0]))
|
||||
}
|
||||
n, e := socketcall(_RECVFROM, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||
var base uintptr
|
||||
if len(p) > 0 {
|
||||
base = uintptr(unsafe.Pointer(&p[0]))
|
||||
}
|
||||
_, e := socketcall(_SENDTO, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen))
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||
n, e := socketcall(_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||
n, e := socketcall(_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Listen(s int, n int) (err error) {
|
||||
_, e := socketcall(_LISTEN, uintptr(s), uintptr(n), 0, 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Shutdown(s, how int) (err error) {
|
||||
_, e := socketcall(_SHUTDOWN, uintptr(s), uintptr(how), 0, 0, 0, 0)
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Statfs(path string, buf *Statfs_t) (err error) {
|
||||
pathp, err := BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||
if e != 0 {
|
||||
err = e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)) }
|
||||
|
||||
func (r *PtraceRegs) SetPC(pc uint64) { r.Eip = int32(pc) }
|
||||
|
||||
func (iov *Iovec) SetLen(length int) {
|
||||
iov.Len = uint32(length)
|
||||
}
|
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) {
|
||||
msghdr.Controllen = uint32(length)
|
||||
}
|
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||
cmsg.Len = uint32(length)
|
||||
}
|
||||
|
||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||
|
||||
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||
if len(fds) == 0 {
|
||||
return poll(nil, 0, timeout)
|
||||
}
|
||||
return poll(&fds[0], len(fds), timeout)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user