Файловый менеджер - Редактировать - /var/www/html/route.zip
Ðазад
PK ! �+�� � sys_freebsd.gonu �[��� // 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 } // 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])), }, } } // 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])), }, } } var compatFreeBSD32 bool // 386 emulation on amd64 func probeRoutingStack() (int, map[int]*wireFormat) { var p uintptr wordSize := int(unsafe.Sizeof(p)) align := wordSize // 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 } } if align != wordSize { compatFreeBSD32 = true // 386 emulation on amd64 } var rtm, ifm, ifam, ifmam, ifanm *wireFormat if compatFreeBSD32 { 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 compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD7Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD7 } case 800000 <= rel && rel < 900000: if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD8Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD8 } case 900000 <= rel && rel < 1000000: if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD9Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD9 } case 1000000 <= rel && rel < 1100000: if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD10Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD10 } default: if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD11Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD11 } } rtm.parse = rtm.parseRouteMessage ifm.parse = ifm.parseInterfaceMessage ifam.parse = ifam.parseInterfaceAddrMessage ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage ifanm.parse = ifanm.parseInterfaceAnnounceMessage return align, map[int]*wireFormat{ syscall.RTM_ADD: rtm, syscall.RTM_DELETE: rtm, syscall.RTM_CHANGE: rtm, syscall.RTM_GET: rtm, syscall.RTM_LOSING: rtm, syscall.RTM_REDIRECT: rtm, syscall.RTM_MISS: rtm, syscall.RTM_LOCK: rtm, syscall.RTM_RESOLVE: rtm, syscall.RTM_NEWADDR: ifam, syscall.RTM_DELADDR: ifam, syscall.RTM_IFINFO: ifm, syscall.RTM_NEWMADDR: ifmam, syscall.RTM_DELMADDR: ifmam, syscall.RTM_IFANNOUNCE: ifanm, } } PK ! ����� � interface.gonu �[��� // 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. //go: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 // 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 *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 } PK ! ��<� � zsys_freebsd_386.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_freebsd.go package route 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 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! v��� � interface_freebsd.gonu �[��� // 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" func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, error) { var extOff, bodyOff int if typ == syscall.NET_RT_IFLISTL { if len(b) < 20 { return nil, errMessageTooShort } extOff = int(nativeEndian.Uint16(b[18:20])) bodyOff = int(nativeEndian.Uint16(b[16:18])) } else { extOff = w.extOff bodyOff = w.bodyOff } if len(b) < extOff || len(b) < bodyOff { return nil, errInvalidMessage } l := int(nativeEndian.Uint16(b[:2])) if len(b) < l { return nil, errInvalidMessage } attrs := uint(nativeEndian.Uint32(b[4:8])) if attrs&syscall.RTA_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, syscall.RTAX_MAX), extOff: extOff, raw: b[:l], } a, err := parseLinkAddr(b[bodyOff:]) if err != nil { return nil, err } m.Addrs[syscall.RTAX_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 == syscall.NET_RT_IFLISTL { if len(b) < 24 { return nil, errMessageTooShort } bodyOff = int(nativeEndian.Uint16(b[16:18])) } else { bodyOff = w.bodyOff } if len(b) < bodyOff { return nil, errInvalidMessage } 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 } PK ! �> sys_darwin.gonu �[��� // 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" func (typ RIBType) parseable() bool { switch typ { case syscall.NET_RT_STAT, syscall.NET_RT_TRASH: return false default: return true } } // 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])), }, } } // 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]*wireFormat) { rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15} rtm.parse = rtm.parseRouteMessage rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15} rtm2.parse = rtm2.parseRouteMessage ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15} ifm.parse = ifm.parseInterfaceMessage ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15} ifm2.parse = ifm2.parseInterfaceMessage ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15} ifam.parse = ifam.parseInterfaceAddrMessage ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15} ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15} ifmam2.parse = ifmam2.parseInterfaceMulticastAddrMessage // Darwin kernels require 32-bit aligned access to routing facilities. return 4, map[int]*wireFormat{ syscall.RTM_ADD: rtm, syscall.RTM_DELETE: rtm, syscall.RTM_CHANGE: rtm, syscall.RTM_GET: rtm, syscall.RTM_LOSING: rtm, syscall.RTM_REDIRECT: rtm, syscall.RTM_MISS: rtm, syscall.RTM_LOCK: rtm, syscall.RTM_RESOLVE: rtm, syscall.RTM_NEWADDR: ifam, syscall.RTM_DELADDR: ifam, syscall.RTM_IFINFO: ifm, syscall.RTM_NEWMADDR: ifmam, syscall.RTM_DELMADDR: ifmam, syscall.RTM_IFINFO2: ifm2, syscall.RTM_NEWMADDR2: ifmam2, syscall.RTM_GET2: rtm2, } } PK ! Y�� � syscall.gonu �[��� // 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. //go:build darwin || dragonfly || freebsd || netbsd || openbsd package route import _ "unsafe" // for linkname //go:linkname sysctl syscall.sysctl func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error PK ! :v^� � route.gonu �[��� // 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. //go: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 and above, 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") errShortBuffer = errors.New("short buffer") ) // A RouteMessage represents a message conveying an address prefix, a // nexthop address and an output interface. // // Unlike other messages, this message can be used to query adjacency // information for the given address prefix, to add a new route, and // to delete or modify the existing route from the routing information // base inside the kernel by writing and reading route messages on a // routing socket. // // For the manipulation of routing information, the route message must // contain appropriate fields that include: // // Version = <must be specified> // Type = <must be specified> // Flags = <must be specified> // Index = <must be specified if necessary> // ID = <must be specified> // Seq = <must be specified> // Addrs = <must be specified> // // The Type field specifies a type of manipulation, the Flags field // specifies a class of target information and the Addrs field // specifies target information like the following: // // route.RouteMessage{ // Version: RTM_VERSION, // Type: RTM_GET, // Flags: RTF_UP | RTF_HOST, // ID: uintptr(os.Getpid()), // Seq: 1, // Addrs: []route.Addrs{ // RTAX_DST: &route.Inet4Addr{ ... }, // RTAX_IFP: &route.LinkAddr{ ... }, // RTAX_BRD: &route.Inet4Addr{ ... }, // }, // } // // The values for the above fields depend on the implementation of // each operating system. // // The Err field on a response message contains an error value on the // requested operation. If non-nil, the requested operation is failed. type RouteMessage struct { Version int // message version Type int // message type Flags int // route flags Index int // interface index when attached ID uintptr // sender's identifier; usually process ID Seq int // sequence number Err error // error on requested operation Addrs []Addr // addresses extOff int // offset of header extension raw []byte // raw message } // Marshal returns the binary encoding of m. func (m *RouteMessage) Marshal() ([]byte, error) { return m.marshal() } // A RIBType represents 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) { try := 0 for { try++ mib := [6]int32{syscall.CTL_NET, syscall.AF_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 { // If the sysctl failed because the data got larger // between the two sysctl calls, try a few times // before failing. (golang.org/issue/45736). const maxTries = 3 if err == syscall.ENOMEM && try < maxTries { continue } return nil, os.NewSyscallError("sysctl", err) } return b[:n], nil } } PK ! � C~� � zsys_freebsd_riscv64.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_freebsd.go package route 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 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! G��{= = interface_multicast.gonu �[��� // 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. //go: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 } PK ! �M='y y sys_openbsd.gonu �[��� // 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 { switch typ { case syscall.NET_RT_STATS, syscall.NET_RT_TABLE: return false default: return true } } // 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])), }, } } // 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]*wireFormat) { var p uintptr rtm := &wireFormat{extOff: -1, bodyOff: -1} rtm.parse = rtm.parseRouteMessage ifm := &wireFormat{extOff: -1, bodyOff: -1} ifm.parse = ifm.parseInterfaceMessage ifam := &wireFormat{extOff: -1, bodyOff: -1} ifam.parse = ifam.parseInterfaceAddrMessage ifanm := &wireFormat{extOff: -1, bodyOff: -1} ifanm.parse = ifanm.parseInterfaceAnnounceMessage return int(unsafe.Sizeof(p)), map[int]*wireFormat{ syscall.RTM_ADD: rtm, syscall.RTM_DELETE: rtm, syscall.RTM_CHANGE: rtm, syscall.RTM_GET: rtm, syscall.RTM_LOSING: rtm, syscall.RTM_REDIRECT: rtm, syscall.RTM_MISS: rtm, syscall.RTM_RESOLVE: rtm, syscall.RTM_NEWADDR: ifam, syscall.RTM_DELADDR: ifam, syscall.RTM_IFINFO: ifm, syscall.RTM_IFANNOUNCE: ifanm, syscall.RTM_DESYNC: rtm, } } PK ! ��-Cw w zsys_netbsd.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_netbsd.go package route const ( sizeofIfMsghdrNetBSD7 = 0x98 sizeofIfaMsghdrNetBSD7 = 0x18 sizeofIfAnnouncemsghdrNetBSD7 = 0x18 sizeofRtMsghdrNetBSD7 = 0x78 sizeofRtMetricsNetBSD7 = 0x50 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! ��" " message.gonu �[��� // 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. //go:build darwin || dragonfly || freebsd || netbsd || openbsd package route // A Message represents a routing message. 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 l == 0 { return nil, errInvalidMessage } if len(b) < l { return nil, errMessageTooShort } if b[2] != rtmVersion { b = b[l:] continue } if w, ok := wireFormats[int(b[3])]; !ok { nskips++ } else { m, err := w.parse(typ, b[:l]) 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 } PK ! �#�E� � interface_classic.gonu �[��� // 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. //go:build darwin || dragonfly || netbsd package route import ( "runtime" "syscall" ) 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&syscall.RTA_IFP == 0 { return nil, nil } m := &InterfaceMessage{ Version: int(b[2]), Type: int(b[3]), Addrs: make([]Addr, syscall.RTAX_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[syscall.RTAX_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 } PK ! �˦w� � zsys_openbsd.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_openbsd.go package route const ( sizeofRtMsghdr = 0x60 sizeofSockaddrStorage = 0x100 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! �L�Ml l route_classic.gonu �[��� // 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. //go:build darwin || dragonfly || freebsd || netbsd package route import ( "runtime" "syscall" ) func (m *RouteMessage) marshal() ([]byte, error) { w, ok := wireFormats[m.Type] if !ok { return nil, errUnsupportedMessage } l := w.bodyOff + addrsSpace(m.Addrs) if runtime.GOOS == "darwin" || runtime.GOOS == "ios" { // Fix stray pointer writes on macOS. // See golang.org/issue/22456. l += 1024 } b := make([]byte, l) nativeEndian.PutUint16(b[:2], uint16(l)) if m.Version == 0 { b[2] = rtmVersion } else { b[2] = byte(m.Version) } b[3] = byte(m.Type) nativeEndian.PutUint32(b[8:12], uint32(m.Flags)) nativeEndian.PutUint16(b[4:6], uint16(m.Index)) nativeEndian.PutUint32(b[16:20], uint32(m.ID)) nativeEndian.PutUint32(b[20:24], uint32(m.Seq)) attrs, err := marshalAddrs(b[w.bodyOff:], m.Addrs) if err != nil { return nil, err } if attrs > 0 { nativeEndian.PutUint32(b[12:16], uint32(attrs)) } return b, nil } 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])), ID: uintptr(nativeEndian.Uint32(b[16:20])), Seq: int(nativeEndian.Uint32(b[20:24])), extOff: w.extOff, raw: b[:l], } errno := syscall.Errno(nativeEndian.Uint32(b[28:32])) if errno != 0 { m.Err = errno } 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 } PK ! N��� � route_openbsd.gonu �[��� // 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" ) func (m *RouteMessage) marshal() ([]byte, error) { l := sizeofRtMsghdr + addrsSpace(m.Addrs) b := make([]byte, l) nativeEndian.PutUint16(b[:2], uint16(l)) if m.Version == 0 { b[2] = syscall.RTM_VERSION } else { b[2] = byte(m.Version) } b[3] = byte(m.Type) nativeEndian.PutUint16(b[4:6], uint16(sizeofRtMsghdr)) nativeEndian.PutUint32(b[16:20], uint32(m.Flags)) nativeEndian.PutUint16(b[6:8], uint16(m.Index)) nativeEndian.PutUint32(b[24:28], uint32(m.ID)) nativeEndian.PutUint32(b[28:32], uint32(m.Seq)) attrs, err := marshalAddrs(b[sizeofRtMsghdr:], m.Addrs) if err != nil { return nil, err } if attrs > 0 { nativeEndian.PutUint32(b[12:16], uint32(attrs)) } return b, nil } func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) { if len(b) < sizeofRtMsghdr { 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])), ID: uintptr(nativeEndian.Uint32(b[24:28])), Seq: int(nativeEndian.Uint32(b[28:32])), raw: b[:l], } ll := int(nativeEndian.Uint16(b[4:6])) if len(b) < ll { return nil, errInvalidMessage } errno := syscall.Errno(nativeEndian.Uint32(b[32:36])) if errno != 0 { m.Err = errno } as, err := parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[ll:]) if err != nil { return nil, err } m.Addrs = as return m, nil } PK ! q�� � zsys_freebsd_arm.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_freebsd.go package route 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 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! Z5�� zsys_darwin.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_darwin.go package route const ( sizeofIfMsghdrDarwin15 = 0x70 sizeofIfaMsghdrDarwin15 = 0x14 sizeofIfmaMsghdrDarwin15 = 0x10 sizeofIfMsghdr2Darwin15 = 0xa0 sizeofIfmaMsghdr2Darwin15 = 0x14 sizeofIfDataDarwin15 = 0x60 sizeofIfData64Darwin15 = 0x80 sizeofRtMsghdrDarwin15 = 0x5c sizeofRtMsghdr2Darwin15 = 0x5c sizeofRtMetricsDarwin15 = 0x38 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! 3Þ� � sys_netbsd.gonu �[��� // 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" func (typ RIBType) parseable() bool { return true } // 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])), }, } } // RouteMetrics represents route 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]*wireFormat) { rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7} rtm.parse = rtm.parseRouteMessage ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7} ifm.parse = ifm.parseInterfaceMessage ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7} ifam.parse = ifam.parseInterfaceAddrMessage ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7} ifanm.parse = ifanm.parseInterfaceAnnounceMessage // NetBSD 6 and above kernels require 64-bit aligned access to // routing facilities. return 8, map[int]*wireFormat{ syscall.RTM_ADD: rtm, syscall.RTM_DELETE: rtm, syscall.RTM_CHANGE: rtm, syscall.RTM_GET: rtm, syscall.RTM_LOSING: rtm, syscall.RTM_REDIRECT: rtm, syscall.RTM_MISS: rtm, syscall.RTM_LOCK: rtm, syscall.RTM_RESOLVE: rtm, syscall.RTM_NEWADDR: ifam, syscall.RTM_DELADDR: ifam, syscall.RTM_IFANNOUNCE: ifanm, syscall.RTM_IFINFO: ifm, } } PK ! [n�� � binary.gonu �[��� // 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. //go: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 the 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 } PK ! I�I�� � zsys_dragonfly.gonu �[��� // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_dragonfly.go package route const ( sizeofIfMsghdrDragonFlyBSD4 = 0xb0 sizeofIfaMsghdrDragonFlyBSD4 = 0x14 sizeofIfmaMsghdrDragonFlyBSD4 = 0x10 sizeofIfAnnouncemsghdrDragonFlyBSD4 = 0x18 sizeofIfaMsghdrDragonFlyBSD58 = 0x18 sizeofRtMsghdrDragonFlyBSD4 = 0x98 sizeofRtMetricsDragonFlyBSD4 = 0x70 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 sizeofSockaddrInet6 = 0x1c ) PK ! .�s�'