1
2
3
4
5 package route
6
7 func (typ RIBType) parseable() bool { return true }
8
9
10 type RouteMetrics struct {
11 PathMTU int
12 }
13
14
15 func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
16
17
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
27 type InterfaceMetrics struct {
28 Type int
29 MTU int
30 }
31
32
33 func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
34
35
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
55
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 }
72
View as plain text