Source file src/internal/routebsd/sys_dragonfly.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  package routebsd
     6  
     7  import (
     8  	"syscall"
     9  	"unsafe"
    10  )
    11  
    12  // MTU returns the interface MTU.
    13  func (m *InterfaceMessage) MTU() int {
    14  	return int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12]))
    15  }
    16  
    17  func probeRoutingStack() (int, map[int]*wireFormat) {
    18  	var p uintptr
    19  	ifm := &wireFormat{extOff: 16, bodyOff: syscall.SizeofIfMsghdr}
    20  	ifm.parse = ifm.parseInterfaceMessage
    21  	ifam := &wireFormat{extOff: syscall.SizeofIfaMsghdr, bodyOff: syscall.SizeofIfaMsghdr}
    22  	ifam.parse = ifam.parseInterfaceAddrMessage
    23  	ifmam := &wireFormat{extOff: syscall.SizeofIfmaMsghdr, bodyOff: syscall.SizeofIfmaMsghdr}
    24  	ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage
    25  
    26  	rel, _ := syscall.SysctlUint32("kern.osreldate")
    27  	if rel >= 500705 {
    28  		// https://github.com/DragonFlyBSD/DragonFlyBSD/commit/43a373152df2d405c9940983e584e6a25e76632d
    29  		// but only the size of struct ifa_msghdr actually changed
    30  		rtmVersion = 7
    31  		ifam.bodyOff = 0x18
    32  	}
    33  
    34  	return int(unsafe.Sizeof(p)), map[int]*wireFormat{
    35  		syscall.RTM_NEWADDR:  ifam,
    36  		syscall.RTM_DELADDR:  ifam,
    37  		syscall.RTM_IFINFO:   ifm,
    38  		syscall.RTM_NEWMADDR: ifmam,
    39  		syscall.RTM_DELMADDR: ifmam,
    40  	}
    41  }
    42  

View as plain text