Source file src/syscall/route_freebsd_32bit.go

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

View as plain text