...

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

Documentation: vendor/golang.org/x/net/route

     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  
     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  	// might get overridden in probeRoutingStack
    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 // offset of header extension
    43  	bodyOff int // offset of message body
    44  	parse   func(RIBType, []byte) (Message, error)
    45  }
    46  

View as plain text