github.com/lianghucheng/zrddz@v0.0.0-20200923083010-c71f680932e2/src/golang.org/x/net/route/sys_netbsd.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package route 6 7 func (typ RIBType) parseable() bool { return true } 8 9 // RouteMetrics represents route metrics. 10 type RouteMetrics struct { 11 PathMTU int // path maximum transmission unit 12 } 13 14 // SysType implements the SysType method of Sys interface. 15 func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } 16 17 // Sys implements the Sys method of Message interface. 18 func (m *RouteMessage) Sys() []Sys { 19 return []Sys{ 20 &RouteMetrics{ 21 PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), 22 }, 23 } 24 } 25 26 // RouteMetrics represents route metrics. 27 type InterfaceMetrics struct { 28 Type int // interface type 29 MTU int // maximum transmission unit 30 } 31 32 // SysType implements the SysType method of Sys interface. 33 func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } 34 35 // Sys implements the Sys method of Message interface. 36 func (m *InterfaceMessage) Sys() []Sys { 37 return []Sys{ 38 &InterfaceMetrics{ 39 Type: int(m.raw[m.extOff]), 40 MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), 41 }, 42 } 43 } 44 45 func probeRoutingStack() (int, map[int]*wireFormat) { 46 rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7} 47 rtm.parse = rtm.parseRouteMessage 48 ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7} 49 ifm.parse = ifm.parseInterfaceMessage 50 ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7} 51 ifam.parse = ifam.parseInterfaceAddrMessage 52 ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7} 53 ifanm.parse = ifanm.parseInterfaceAnnounceMessage 54 // NetBSD 6 and above kernels require 64-bit aligned access to 55 // routing facilities. 56 return 8, map[int]*wireFormat{ 57 sysRTM_ADD: rtm, 58 sysRTM_DELETE: rtm, 59 sysRTM_CHANGE: rtm, 60 sysRTM_GET: rtm, 61 sysRTM_LOSING: rtm, 62 sysRTM_REDIRECT: rtm, 63 sysRTM_MISS: rtm, 64 sysRTM_LOCK: rtm, 65 sysRTM_RESOLVE: rtm, 66 sysRTM_NEWADDR: ifam, 67 sysRTM_DELADDR: ifam, 68 sysRTM_IFANNOUNCE: ifanm, 69 sysRTM_IFINFO: ifm, 70 } 71 }