1
2
3
4
5 package route
6
7 import "syscall"
8
9 func (typ RIBType) parseable() bool { return true }
10
11
12 type RouteMetrics struct {
13 PathMTU int
14 }
15
16
17 func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
18
19
20 func (m *RouteMessage) Sys() []Sys {
21 return []Sys{
22 &RouteMetrics{
23 PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])),
24 },
25 }
26 }
27
28
29 type InterfaceMetrics struct {
30 Type int
31 MTU int
32 }
33
34
35 func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
36
37
38 func (m *InterfaceMessage) Sys() []Sys {
39 return []Sys{
40 &InterfaceMetrics{
41 Type: int(m.raw[m.extOff]),
42 MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
43 },
44 }
45 }
46
47 func probeRoutingStack() (int, map[int]*wireFormat) {
48 rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7}
49 rtm.parse = rtm.parseRouteMessage
50 ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7}
51 ifm.parse = ifm.parseInterfaceMessage
52 ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7}
53 ifam.parse = ifam.parseInterfaceAddrMessage
54 ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7}
55 ifanm.parse = ifanm.parseInterfaceAnnounceMessage
56
57
58 return 8, map[int]*wireFormat{
59 syscall.RTM_ADD: rtm,
60 syscall.RTM_DELETE: rtm,
61 syscall.RTM_CHANGE: rtm,
62 syscall.RTM_GET: rtm,
63 syscall.RTM_LOSING: rtm,
64 syscall.RTM_REDIRECT: rtm,
65 syscall.RTM_MISS: rtm,
66 syscall.RTM_LOCK: rtm,
67 syscall.RTM_RESOLVE: rtm,
68 syscall.RTM_NEWADDR: ifam,
69 syscall.RTM_DELADDR: ifam,
70 syscall.RTM_IFANNOUNCE: ifanm,
71 syscall.RTM_IFINFO: ifm,
72 }
73 }
74
View as plain text