1
2
3
4
5 package route
6
7 import "unsafe"
8
9 func (typ RIBType) parseable() bool {
10 switch typ {
11 case sysNET_RT_STATS, sysNET_RT_TABLE:
12 return false
13 default:
14 return true
15 }
16 }
17
18
19 type RouteMetrics struct {
20 PathMTU int
21 }
22
23
24 func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
25
26
27 func (m *RouteMessage) Sys() []Sys {
28 return []Sys{
29 &RouteMetrics{
30 PathMTU: int(nativeEndian.Uint32(m.raw[60:64])),
31 },
32 }
33 }
34
35
36 type InterfaceMetrics struct {
37 Type int
38 MTU int
39 }
40
41
42 func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
43
44
45 func (m *InterfaceMessage) Sys() []Sys {
46 return []Sys{
47 &InterfaceMetrics{
48 Type: int(m.raw[24]),
49 MTU: int(nativeEndian.Uint32(m.raw[28:32])),
50 },
51 }
52 }
53
54 func probeRoutingStack() (int, map[int]*wireFormat) {
55 var p uintptr
56 rtm := &wireFormat{extOff: -1, bodyOff: -1}
57 rtm.parse = rtm.parseRouteMessage
58 ifm := &wireFormat{extOff: -1, bodyOff: -1}
59 ifm.parse = ifm.parseInterfaceMessage
60 ifam := &wireFormat{extOff: -1, bodyOff: -1}
61 ifam.parse = ifam.parseInterfaceAddrMessage
62 ifanm := &wireFormat{extOff: -1, bodyOff: -1}
63 ifanm.parse = ifanm.parseInterfaceAnnounceMessage
64 return int(unsafe.Sizeof(p)), map[int]*wireFormat{
65 sysRTM_ADD: rtm,
66 sysRTM_DELETE: rtm,
67 sysRTM_CHANGE: rtm,
68 sysRTM_GET: rtm,
69 sysRTM_LOSING: rtm,
70 sysRTM_REDIRECT: rtm,
71 sysRTM_MISS: rtm,
72 sysRTM_LOCK: rtm,
73 sysRTM_RESOLVE: rtm,
74 sysRTM_NEWADDR: ifam,
75 sysRTM_DELADDR: ifam,
76 sysRTM_IFINFO: ifm,
77 sysRTM_IFANNOUNCE: ifanm,
78 sysRTM_DESYNC: rtm,
79 }
80 }
81
View as plain text