// Copyright 2012 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 ipv4

import (
	

	
)

// MulticastTTL returns the time-to-live field value for outgoing
// multicast packets.
func ( *dgramOpt) () (int, error) {
	if !.ok() {
		return 0, errInvalidConn
	}
	,  := sockOpts[ssoMulticastTTL]
	if ! {
		return 0, errNotImplemented
	}
	return .GetInt(.Conn)
}

// SetMulticastTTL sets the time-to-live field value for future
// outgoing multicast packets.
func ( *dgramOpt) ( int) error {
	if !.ok() {
		return errInvalidConn
	}
	,  := sockOpts[ssoMulticastTTL]
	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
	}
	 := netAddrToIP4()
	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
	}
	 := netAddrToIP4()
	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
	}
	 := netAddrToIP4()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP4()
	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
	}
	 := netAddrToIP4()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP4()
	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
	}
	 := netAddrToIP4()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP4()
	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
	}
	 := netAddrToIP4()
	if  == nil {
		return errMissingAddress
	}
	 := netAddrToIP4()
	if  == nil {
		return errMissingAddress
	}
	return .setSourceGroup(.Conn, , , )
}

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

// SetICMPFilter deploys the ICMP filter.
// Currently only Linux supports this.
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, )
}