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