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.
7 func (typ RIBType) parseable() bool {
9 case sysNET_RT_STAT, sysNET_RT_TRASH:
16 // RouteMetrics represents route metrics.
17 type RouteMetrics struct {
18 PathMTU int // path maximum transmission unit
21 // SysType implements the SysType method of Sys interface.
22 func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
24 // Sys implements the Sys method of Message interface.
25 func (m *RouteMessage) Sys() []Sys {
28 PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])),
33 // InterfaceMetrics represents interface metrics.
34 type InterfaceMetrics struct {
35 Type int // interface type
36 MTU int // maximum transmission unit
39 // SysType implements the SysType method of Sys interface.
40 func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
42 // Sys implements the Sys method of Message interface.
43 func (m *InterfaceMessage) Sys() []Sys {
46 Type: int(m.raw[m.extOff]),
47 MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
52 func probeRoutingStack() (int, map[int]*wireFormat) {
53 rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15}
54 rtm.parse = rtm.parseRouteMessage
55 rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15}
56 rtm2.parse = rtm2.parseRouteMessage
57 ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15}
58 ifm.parse = ifm.parseInterfaceMessage
59 ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15}
60 ifm2.parse = ifm2.parseInterfaceMessage
61 ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15}
62 ifam.parse = ifam.parseInterfaceAddrMessage
63 ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15}
64 ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage
65 ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15}
66 ifmam2.parse = ifmam2.parseInterfaceMulticastAddrMessage
67 // Darwin kernels require 32-bit aligned access to routing facilities.
68 return 4, map[int]*wireFormat{
81 sysRTM_NEWMADDR: ifmam,
82 sysRTM_DELMADDR: ifmam,
84 sysRTM_NEWMADDR2: ifmam2,