1
2
3
4
5
6
7
8 package route
9
10 import "unsafe"
11
12 var (
13 nativeEndian binaryByteOrder
14 kernelAlign int
15 rtmVersion byte
16 wireFormats map[int]*wireFormat
17 )
18
19 func init() {
20 i := uint32(1)
21 b := (*[4]byte)(unsafe.Pointer(&i))
22 if b[0] == 1 {
23 nativeEndian = littleEndian
24 } else {
25 nativeEndian = bigEndian
26 }
27
28 rtmVersion = sysRTM_VERSION
29 kernelAlign, wireFormats = probeRoutingStack()
30 }
31
32 func roundup(l int) int {
33 if l == 0 {
34 return kernelAlign
35 }
36 return (l + kernelAlign - 1) &^ (kernelAlign - 1)
37 }
38
39 type wireFormat struct {
40 extOff int
41 bodyOff int
42 parse func(RIBType, []byte) (Message, error)
43 }
44
View as plain text