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

package ipv6

import (
	

	
)

// MulticastHopLimit returns the hop limit field value for outgoing
// multicast packets.
func ( *dgramOpt) () (int, error) {
	if !.ok() {
		return 0, errInvalidConn
	}
	,  := sockOpts[ssoMulticastHopLimit]
	if ! {
		return 0, errNotImplemented
	}
	return .GetInt(.Conn)
}

// SetMulticastHopLimit sets the hop limit field value for future
// outgoing multicast packets.
func ( *dgramOpt) ( int) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoMulticastHopLimit]
	if ! {
		return errNotImplemented
	}
	return .SetInt(.Conn, )
}

// MulticastInterface returns the default interface for multicast
// packet transmissions.
func ( *dgramOpt) () (*net.Interface, error) {
	if !.ok() {
		return nil, errInvalidConn
	}
	,  := sockOpts[ssoMulticastInterface]
	if ! {
		return nil, errNotImplemented
	}
	return .getMulticastInterface(.Conn)
}

// SetMulticastInterface sets the default interface for future
// multicast packet transmissions.
func ( *dgramOpt) ( *net.Interface) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoMulticastInterface]
	if ! {
		return errNotImplemented
	}
	return .setMulticastInterface(.Conn, )
}

// MulticastLoopback reports whether transmitted multicast packets
// should be copied and send back to the originator.
func ( *dgramOpt) () (bool, error) {
	if !.ok() {
		return false, errInvalidConn
	}
	,  := sockOpts[ssoMulticastLoopback]
	if ! {
		return false, errNotImplemented
	}
	,  := .GetInt(.Conn)
	if  != nil {
		return false, 
	}
	return  == 1, nil
}

// SetMulticastLoopback sets whether transmitted multicast packets
// should be copied and send back to the originator.
func ( *dgramOpt) ( bool) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoMulticastLoopback]
	if ! {
		return errNotImplemented
	}
	return .SetInt(.Conn, boolint())
}

// JoinGroup joins the group address group on the interface ifi.
// By default all sources that can cast data to group are accepted.
// It's possible to mute and unmute data transmission from a specific
// source by using ExcludeSourceSpecificGroup and
// IncludeSourceSpecificGroup.
// JoinGroup uses the system assigned multicast interface when ifi is
// nil, although this is not recommended because the assignment
// depends on platforms and sometimes it might require routing
// configuration.
func ( *dgramOpt) ( *net.Interface,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoJoinGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setGroup(.Conn, , )
}

// LeaveGroup leaves the group address group on the interface ifi
// regardless of whether the group is any-source group or
// source-specific group.
func ( *dgramOpt) ( *net.Interface,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoLeaveGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setGroup(.Conn, , )
}

// JoinSourceSpecificGroup joins the source-specific group comprising
// group and source on the interface ifi.
// JoinSourceSpecificGroup uses the system assigned multicast
// interface when ifi is nil, although this is not recommended because
// the assignment depends on platforms and sometimes it might require
// routing configuration.
func ( *dgramOpt) ( *net.Interface, ,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoJoinSourceGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setSourceGroup(.Conn, , , )
}

// LeaveSourceSpecificGroup leaves the source-specific group on the
// interface ifi.
func ( *dgramOpt) ( *net.Interface, ,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoLeaveSourceGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setSourceGroup(.Conn, , , )
}

// ExcludeSourceSpecificGroup excludes the source-specific group from
// the already joined any-source groups by JoinGroup on the interface
// ifi.
func ( *dgramOpt) ( *net.Interface, ,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoBlockSourceGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setSourceGroup(.Conn, , , )
}

// IncludeSourceSpecificGroup includes the excluded source-specific
// group by ExcludeSourceSpecificGroup again on the interface ifi.
func ( *dgramOpt) ( *net.Interface, ,  net.Addr) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoUnblockSourceGroup]
	if ! {
		return errNotImplemented
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP16()
	if  == nil {
		return errMissingAddress
	}
	return .setSourceGroup(.Conn, , , )
}

// Checksum reports whether the kernel will compute, store or verify a
// checksum for both incoming and outgoing packets. If on is true, it
// returns an offset in bytes into the data of where the checksum
// field is located.
func ( *dgramOpt) () ( bool,  int,  error) {
	if !.ok() {
		return false, 0, errInvalidConn
	}
	,  := sockOpts[ssoChecksum]
	if ! {
		return false, 0, errNotImplemented
	}
	,  = .GetInt(.Conn)
	if  != nil {
		return false, 0, 
	}
	if  < 0 {
		return false, 0, nil
	}
	return true, , nil
}

// SetChecksum enables the kernel checksum processing. If on is true,
// the offset should be an offset in bytes into the data of where the
// checksum field is located.
func ( *dgramOpt) ( bool,  int) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoChecksum]
	if ! {
		return errNotImplemented
	}
	if ! {
		 = -1
	}
	return .SetInt(.Conn, )
}

// ICMPFilter returns an ICMP filter.
func ( *dgramOpt) () (*ICMPFilter, error) {
	if !.ok() {
		return nil, errInvalidConn
	}
	,  := sockOpts[ssoICMPFilter]
	if ! {
		return nil, errNotImplemented
	}
	return .getICMPFilter(.Conn)
}

// SetICMPFilter deploys the ICMP filter.
func ( *dgramOpt) ( *ICMPFilter) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoICMPFilter]
	if ! {
		return errNotImplemented
	}
	return .setICMPFilter(.Conn, )
}

// SetBPF attaches a BPF program to the connection.
//
// Only supported on Linux.
func ( *dgramOpt) ( []bpf.RawInstruction) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoAttachFilter]
	if ! {
		return errNotImplemented
	}
	return .setBPF(.Conn, )
}