// Copyright 2013 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.

//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos

package ipv6

import (
	
	

	
	

	
)

func marshalTrafficClass( []byte,  *ControlMessage) []byte {
	 := socket.ControlMessage()
	.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_TCLASS, 4)
	if  != nil {
		socket.NativeEndian.PutUint32(.Data(4), uint32(.TrafficClass))
	}
	return .Next(4)
}

func parseTrafficClass( *ControlMessage,  []byte) {
	.TrafficClass = int(socket.NativeEndian.Uint32([:4]))
}

func marshalHopLimit( []byte,  *ControlMessage) []byte {
	 := socket.ControlMessage()
	.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_HOPLIMIT, 4)
	if  != nil {
		socket.NativeEndian.PutUint32(.Data(4), uint32(.HopLimit))
	}
	return .Next(4)
}

func parseHopLimit( *ControlMessage,  []byte) {
	.HopLimit = int(socket.NativeEndian.Uint32([:4]))
}

func marshalPacketInfo( []byte,  *ControlMessage) []byte {
	 := socket.ControlMessage()
	.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_PKTINFO, sizeofInet6Pktinfo)
	if  != nil {
		 := (*inet6Pktinfo)(unsafe.Pointer(&.Data(sizeofInet6Pktinfo)[0]))
		if  := .Src.To16();  != nil && .To4() == nil {
			copy(.Addr[:], )
		}
		if .IfIndex > 0 {
			.setIfindex(.IfIndex)
		}
	}
	return .Next(sizeofInet6Pktinfo)
}

func parsePacketInfo( *ControlMessage,  []byte) {
	 := (*inet6Pktinfo)(unsafe.Pointer(&[0]))
	if len(.Dst) < net.IPv6len {
		.Dst = make(net.IP, net.IPv6len)
	}
	copy(.Dst, .Addr[:])
	.IfIndex = int(.Ifindex)
}

func marshalNextHop( []byte,  *ControlMessage) []byte {
	 := socket.ControlMessage()
	.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_NEXTHOP, sizeofSockaddrInet6)
	if  != nil {
		 := (*sockaddrInet6)(unsafe.Pointer(&.Data(sizeofSockaddrInet6)[0]))
		.setSockaddr(.NextHop, .IfIndex)
	}
	return .Next(sizeofSockaddrInet6)
}

func parseNextHop( *ControlMessage,  []byte) {
}

func marshalPathMTU( []byte,  *ControlMessage) []byte {
	 := socket.ControlMessage()
	.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo)
	return .Next(sizeofIPv6Mtuinfo)
}

func parsePathMTU( *ControlMessage,  []byte) {
	 := (*ipv6Mtuinfo)(unsafe.Pointer(&[0]))
	if len(.Dst) < net.IPv6len {
		.Dst = make(net.IP, net.IPv6len)
	}
	copy(.Dst, .Addr.Addr[:])
	.IfIndex = int(.Addr.Scope_id)
	.MTU = int(.Mtu)
}