Black Lives Matter. Support the Equal Justice Initiative.

Source file src/syscall/route_freebsd_32bit.go

Documentation: syscall

     1  // Copyright 2014 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 (freebsd && 386) || (freebsd && arm)
     6  // +build freebsd,386 freebsd,arm
     7  
     8  package syscall
     9  
    10  import "unsafe"
    11  
    12  func (any *anyMessage) parseRouteMessage(b []byte) *RouteMessage {
    13  	p := (*RouteMessage)(unsafe.Pointer(any))
    14  	off := int(unsafe.Offsetof(p.Header.Rmx)) + SizeofRtMetrics
    15  	if freebsdConfArch == "amd64" {
    16  		off += SizeofRtMetrics // rt_metrics on amd64 is simply doubled
    17  	}
    18  	return &RouteMessage{Header: p.Header, Data: b[rsaAlignOf(off):any.Msglen]}
    19  }
    20  
    21  func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
    22  	p := (*InterfaceMessage)(unsafe.Pointer(any))
    23  	// FreeBSD 10 and beyond have a restructured mbuf
    24  	// packet header view.
    25  	// See https://svnweb.freebsd.org/base?view=revision&revision=254804.
    26  	if supportsABI(1000000) {
    27  		m := (*ifMsghdr)(unsafe.Pointer(any))
    28  		p.Header.Data.Hwassist = uint32(m.Data.Hwassist)
    29  		p.Header.Data.Epoch = m.Data.Epoch
    30  		p.Header.Data.Lastchange = m.Data.Lastchange
    31  		return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
    32  	}
    33  	return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
    34  }
    35  

View as plain text