github.com/likebike/go--@v0.0.0-20190911215757-0bd925d16e96/go/src/syscall/route_freebsd_32bit.go (about) 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 // +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 http://svnweb.freebsd.org/base?view=revision&revision=254804. 25 if freebsdVersion >= 1000000 { 26 m := (*ifMsghdr)(unsafe.Pointer(any)) 27 p.Header.Data.Hwassist = uint32(m.Data.Hwassist) 28 p.Header.Data.Epoch = m.Data.Epoch 29 p.Header.Data.Lastchange = m.Data.Lastchange 30 return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]} 31 } 32 return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]} 33 }