Source file src/vendor/golang.org/x/net/route/sys.go

     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  
     5  //go:build darwin || dragonfly || freebsd || netbsd || openbsd
     6  // +build darwin dragonfly freebsd netbsd openbsd
     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  	// might get overridden in probeRoutingStack
    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 // offset of header extension
    41  	bodyOff int // offset of message body
    42  	parse   func(RIBType, []byte) (Message, error)
    43  }
    44  

View as plain text