| // 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. |
| func (cm *ControlMessage) marshalPacketInfo() (oob []byte) { |
| if l := cm.oobLen(); l > 0 { |
| m := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0])) |
| m.Type = sysSockoptPacketInfo |
| m.SetLen(syscall.CmsgLen(sysSizeofPacketInfo)) |
| pi := (*sysPacketInfo)(unsafe.Pointer(&oob[syscall.CmsgLen(0)])) |
| if ip := cm.Src.To4(); ip != nil { |
| pi.IfIndex = int32(cm.IfIndex) |