You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
812 B

  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build darwin dragonfly freebsd netbsd openbsd
  5. package route
  6. import "unsafe"
  7. var (
  8. nativeEndian binaryByteOrder
  9. kernelAlign int
  10. wireFormats map[int]*wireFormat
  11. )
  12. func init() {
  13. i := uint32(1)
  14. b := (*[4]byte)(unsafe.Pointer(&i))
  15. if b[0] == 1 {
  16. nativeEndian = littleEndian
  17. } else {
  18. nativeEndian = bigEndian
  19. }
  20. kernelAlign, wireFormats = probeRoutingStack()
  21. }
  22. func roundup(l int) int {
  23. if l == 0 {
  24. return kernelAlign
  25. }
  26. return (l + kernelAlign - 1) & ^(kernelAlign - 1)
  27. }
  28. type wireFormat struct {
  29. extOff int // offset of header extension
  30. bodyOff int // offset of message body
  31. parse func(RIBType, []byte) (Message, error)
  32. }