|
@@ -6,7 +6,6 @@ package ipv4
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"net"
|
|
"net"
|
|
|
- "syscall"
|
|
|
|
|
|
|
|
|
|
"golang.org/x/net/bpf"
|
|
"golang.org/x/net/bpf"
|
|
|
)
|
|
)
|
|
@@ -15,7 +14,7 @@ import (
|
|
|
// multicast packets.
|
|
// multicast packets.
|
|
|
func (c *dgramOpt) MulticastTTL() (int, error) {
|
|
func (c *dgramOpt) MulticastTTL() (int, error) {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return 0, syscall.EINVAL
|
|
|
|
|
|
|
+ return 0, errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastTTL]
|
|
so, ok := sockOpts[ssoMulticastTTL]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -28,7 +27,7 @@ func (c *dgramOpt) MulticastTTL() (int, error) {
|
|
|
// outgoing multicast packets.
|
|
// outgoing multicast packets.
|
|
|
func (c *dgramOpt) SetMulticastTTL(ttl int) error {
|
|
func (c *dgramOpt) SetMulticastTTL(ttl int) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastTTL]
|
|
so, ok := sockOpts[ssoMulticastTTL]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -41,7 +40,7 @@ func (c *dgramOpt) SetMulticastTTL(ttl int) error {
|
|
|
// packet transmissions.
|
|
// packet transmissions.
|
|
|
func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
|
|
func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return nil, syscall.EINVAL
|
|
|
|
|
|
|
+ return nil, errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastInterface]
|
|
so, ok := sockOpts[ssoMulticastInterface]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -54,7 +53,7 @@ func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
|
|
|
// multicast packet transmissions.
|
|
// multicast packet transmissions.
|
|
|
func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
|
|
func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastInterface]
|
|
so, ok := sockOpts[ssoMulticastInterface]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -67,7 +66,7 @@ func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
|
|
|
// should be copied and send back to the originator.
|
|
// should be copied and send back to the originator.
|
|
|
func (c *dgramOpt) MulticastLoopback() (bool, error) {
|
|
func (c *dgramOpt) MulticastLoopback() (bool, error) {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return false, syscall.EINVAL
|
|
|
|
|
|
|
+ return false, errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastLoopback]
|
|
so, ok := sockOpts[ssoMulticastLoopback]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -84,7 +83,7 @@ func (c *dgramOpt) MulticastLoopback() (bool, error) {
|
|
|
// should be copied and send back to the originator.
|
|
// should be copied and send back to the originator.
|
|
|
func (c *dgramOpt) SetMulticastLoopback(on bool) error {
|
|
func (c *dgramOpt) SetMulticastLoopback(on bool) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoMulticastLoopback]
|
|
so, ok := sockOpts[ssoMulticastLoopback]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -104,7 +103,7 @@ func (c *dgramOpt) SetMulticastLoopback(on bool) error {
|
|
|
// configuration.
|
|
// configuration.
|
|
|
func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
|
|
func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoJoinGroup]
|
|
so, ok := sockOpts[ssoJoinGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -122,7 +121,7 @@ func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
|
|
|
// source-specific group.
|
|
// source-specific group.
|
|
|
func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
|
|
func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoLeaveGroup]
|
|
so, ok := sockOpts[ssoLeaveGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -143,7 +142,7 @@ func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
|
|
|
// routing configuration.
|
|
// routing configuration.
|
|
|
func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoJoinSourceGroup]
|
|
so, ok := sockOpts[ssoJoinSourceGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -164,7 +163,7 @@ func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net
|
|
|
// interface ifi.
|
|
// interface ifi.
|
|
|
func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoLeaveSourceGroup]
|
|
so, ok := sockOpts[ssoLeaveSourceGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -186,7 +185,7 @@ func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source ne
|
|
|
// ifi.
|
|
// ifi.
|
|
|
func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoBlockSourceGroup]
|
|
so, ok := sockOpts[ssoBlockSourceGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -207,7 +206,7 @@ func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source
|
|
|
// group by ExcludeSourceSpecificGroup again on the interface ifi.
|
|
// group by ExcludeSourceSpecificGroup again on the interface ifi.
|
|
|
func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoUnblockSourceGroup]
|
|
so, ok := sockOpts[ssoUnblockSourceGroup]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -228,7 +227,7 @@ func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source
|
|
|
// Currently only Linux supports this.
|
|
// Currently only Linux supports this.
|
|
|
func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
|
|
func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return nil, syscall.EINVAL
|
|
|
|
|
|
|
+ return nil, errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoICMPFilter]
|
|
so, ok := sockOpts[ssoICMPFilter]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -241,7 +240,7 @@ func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
|
|
|
// Currently only Linux supports this.
|
|
// Currently only Linux supports this.
|
|
|
func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
|
|
func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoICMPFilter]
|
|
so, ok := sockOpts[ssoICMPFilter]
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -255,7 +254,7 @@ func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
|
|
|
// Only supported on Linux.
|
|
// Only supported on Linux.
|
|
|
func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error {
|
|
func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error {
|
|
|
if !c.ok() {
|
|
if !c.ok() {
|
|
|
- return syscall.EINVAL
|
|
|
|
|
|
|
+ return errInvalidConn
|
|
|
}
|
|
}
|
|
|
so, ok := sockOpts[ssoAttachFilter]
|
|
so, ok := sockOpts[ssoAttachFilter]
|
|
|
if !ok {
|
|
if !ok {
|