// Copyright 2014 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// +build darwin linux solarispackageipv4import("net""unsafe""golang.org/x/net/internal/iana""golang.org/x/net/internal/socket")funcmarshalPacketInfo(b[]byte,cm*ControlMessage)[]byte{m:=socket.ControlMessage(b)m.MarshalHeader(iana.ProtocolIP,sysIP_PKTINFO,sizeofInetPktinfo)ifcm!=nil{pi:=(*inetPktinfo)(unsafe.Pointer(&m.Data(sizeofInetPktinfo)[0]))ifip:=cm.Src.To4();ip!=nil{copy(pi.Spec_dst[:],ip)}ifcm.IfIndex>0{pi.setIfindex(cm.IfIndex)}}returnm.Next(sizeofInetPktinfo)}funcparsePacketInfo(cm*ControlMessage,b[]byte){pi:=(*inetPktinfo)(unsafe.Pointer(&b[0]))cm.IfIndex=int(pi.Ifindex)iflen(cm.Dst)<net.IPv4len{cm.Dst=make(net.IP,net.IPv4len)}copy(cm.Dst,pi.Addr[:])}