Commit 15ecf1c9 authored by Mikio Hara's avatar Mikio Hara

x/net/ipv4: add source-specific multicast types, constants

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/173090043
parent 383de39d
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
package ipv4 package ipv4
/* /*
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
*/ */
import "C" import "C"
...@@ -40,14 +42,28 @@ const ( ...@@ -40,14 +42,28 @@ const (
sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo
sysSizeofIPMreq = C.sizeof_struct_ip_mreq sysSizeofIPMreq = C.sizeof_struct_ip_mreq
sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
sysSizeofGroupReq = C.sizeof_struct_group_req
sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
) )
type sysSockaddrStorage C.struct_sockaddr_storage
type sysSockaddrInet C.struct_sockaddr_in
type sysInetPktinfo C.struct_in_pktinfo type sysInetPktinfo C.struct_in_pktinfo
type sysIPMreq C.struct_ip_mreq type sysIPMreq C.struct_ip_mreq
...@@ -55,3 +71,7 @@ type sysIPMreq C.struct_ip_mreq ...@@ -55,3 +71,7 @@ type sysIPMreq C.struct_ip_mreq
type sysIPMreqn C.struct_ip_mreqn type sysIPMreqn C.struct_ip_mreqn
type sysIPMreqSource C.struct_ip_mreq_source type sysIPMreqSource C.struct_ip_mreq_source
type sysGroupReq C.struct_group_req
type sysGroupSourceReq C.struct_group_source_req
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
package ipv4 package ipv4
/* /*
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
*/ */
import "C" import "C"
...@@ -41,14 +43,33 @@ const ( ...@@ -41,14 +43,33 @@ const (
sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
sysSizeofIPMreq = C.sizeof_struct_ip_mreq sysSizeofIPMreq = C.sizeof_struct_ip_mreq
sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
sysSizeofGroupReq = C.sizeof_struct_group_req
sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
) )
type sysSockaddrStorage C.struct_sockaddr_storage
type sysSockaddrInet C.struct_sockaddr_in
type sysIPMreq C.struct_ip_mreq type sysIPMreq C.struct_ip_mreq
type sysIPMreqn C.struct_ip_mreqn type sysIPMreqn C.struct_ip_mreqn
type sysIPMreqSource C.struct_ip_mreq_source type sysIPMreqSource C.struct_ip_mreq_source
type sysGroupReq C.struct_group_req
type sysGroupSourceReq C.struct_group_source_req
...@@ -47,6 +47,14 @@ const ( ...@@ -47,6 +47,14 @@ const (
sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP
sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
sysIP_MSFILTER = C.IP_MSFILTER
sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
sysMCAST_MSFILTER = C.MCAST_MSFILTER
sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL
sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT
...@@ -63,14 +71,22 @@ const ( ...@@ -63,14 +71,22 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS
sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING
sysSizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage
sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo
sysSizeofSockExtendedErr = C.sizeof_struct_sock_extended_err sysSizeofSockExtendedErr = C.sizeof_struct_sock_extended_err
sysSizeofIPMreq = C.sizeof_struct_ip_mreq sysSizeofIPMreq = C.sizeof_struct_ip_mreq
sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
sysSizeofGroupReq = C.sizeof_struct_group_req
sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
) )
type sysKernelSockaddrStorage C.struct___kernel_sockaddr_storage
type sysSockaddrInet C.struct_sockaddr_in
type sysInetPktinfo C.struct_in_pktinfo type sysInetPktinfo C.struct_in_pktinfo
type sysSockExtendedErr C.struct_sock_extended_err type sysSockExtendedErr C.struct_sock_extended_err
...@@ -80,3 +96,7 @@ type sysIPMreq C.struct_ip_mreq ...@@ -80,3 +96,7 @@ type sysIPMreq C.struct_ip_mreq
type sysIPMreqn C.struct_ip_mreqn type sysIPMreqn C.struct_ip_mreqn
type sysIPMreqSource C.struct_ip_mreq_source type sysIPMreqSource C.struct_ip_mreq_source
type sysGroupReq C.struct_group_req
type sysGroupSourceReq C.struct_group_source_req
...@@ -30,14 +30,40 @@ const ( ...@@ -30,14 +30,40 @@ const (
sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
sysIP_BLOCK_SOURCE = 0x48 sysIP_BLOCK_SOURCE = 0x48
sysIP_UNBLOCK_SOURCE = 0x49 sysIP_UNBLOCK_SOURCE = 0x49
sysMCAST_JOIN_GROUP = 0x50
sysMCAST_LEAVE_GROUP = 0x51
sysMCAST_JOIN_SOURCE_GROUP = 0x52
sysMCAST_LEAVE_SOURCE_GROUP = 0x53
sysMCAST_BLOCK_SOURCE = 0x54
sysMCAST_UNBLOCK_SOURCE = 0x55
sysSizeofSockaddrStorage = 0x80
sysSizeofSockaddrInet = 0x10
sysSizeofInetPktinfo = 0xc sysSizeofInetPktinfo = 0xc
sysSizeofIPMreq = 0x8 sysSizeofIPMreq = 0x8
sysSizeofIPMreqn = 0xc sysSizeofIPMreqn = 0xc
sysSizeofIPMreqSource = 0xc sysSizeofIPMreqSource = 0xc
sysSizeofGroupReq = 0x84
sysSizeofGroupSourceReq = 0x104
) )
type sysSockaddrStorage struct {
Len uint8
Family uint8
X__ss_pad1 [6]int8
X__ss_align int64
X__ss_pad2 [112]int8
}
type sysSockaddrInet struct {
Len uint8
Family uint8
Port uint16
Addr [4]byte /* in_addr */
Zero [8]int8
}
type sysInetPktinfo struct { type sysInetPktinfo struct {
Ifindex uint32 Ifindex uint32
Spec_dst [4]byte /* in_addr */ Spec_dst [4]byte /* in_addr */
...@@ -60,3 +86,14 @@ type sysIPMreqSource struct { ...@@ -60,3 +86,14 @@ type sysIPMreqSource struct {
Sourceaddr [4]byte /* in_addr */ Sourceaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */ Interface [4]byte /* in_addr */
} }
type sysGroupReq struct {
Interface uint32
Pad_cgo_0 [128]byte
}
type sysGroupSourceReq struct {
Interface uint32
Pad_cgo_0 [128]byte
Pad_cgo_1 [128]byte
}
...@@ -31,12 +31,39 @@ const ( ...@@ -31,12 +31,39 @@ const (
sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
sysIP_BLOCK_SOURCE = 0x48 sysIP_BLOCK_SOURCE = 0x48
sysIP_UNBLOCK_SOURCE = 0x49 sysIP_UNBLOCK_SOURCE = 0x49
sysMCAST_JOIN_GROUP = 0x50
sysMCAST_LEAVE_GROUP = 0x51
sysMCAST_JOIN_SOURCE_GROUP = 0x52
sysMCAST_LEAVE_SOURCE_GROUP = 0x53
sysMCAST_BLOCK_SOURCE = 0x54
sysMCAST_UNBLOCK_SOURCE = 0x55
sysSizeofSockaddrStorage = 0x80
sysSizeofSockaddrInet = 0x10
sysSizeofIPMreq = 0x8 sysSizeofIPMreq = 0x8
sysSizeofIPMreqn = 0xc sysSizeofIPMreqn = 0xc
sysSizeofIPMreqSource = 0xc sysSizeofIPMreqSource = 0xc
sysSizeofGroupReq = 0x88
sysSizeofGroupSourceReq = 0x108
) )
type sysSockaddrStorage struct {
Len uint8
Family uint8
X__ss_pad1 [6]int8
X__ss_align int64
X__ss_pad2 [112]int8
}
type sysSockaddrInet struct {
Len uint8
Family uint8
Port uint16
Addr [4]byte /* in_addr */
Zero [8]int8
}
type sysIPMreq struct { type sysIPMreq struct {
Multiaddr [4]byte /* in_addr */ Multiaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */ Interface [4]byte /* in_addr */
...@@ -53,3 +80,16 @@ type sysIPMreqSource struct { ...@@ -53,3 +80,16 @@ type sysIPMreqSource struct {
Sourceaddr [4]byte /* in_addr */ Sourceaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */ Interface [4]byte /* in_addr */
} }
type sysGroupReq struct {
Interface uint32
Pad_cgo_0 [4]byte
Group sysSockaddrStorage
}
type sysGroupSourceReq struct {
Interface uint32
Pad_cgo_0 [4]byte
Group sysSockaddrStorage
Source sysSockaddrStorage
}
...@@ -36,6 +36,14 @@ const ( ...@@ -36,6 +36,14 @@ const (
sysIP_BLOCK_SOURCE = 0x26 sysIP_BLOCK_SOURCE = 0x26
sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
sysIP_MSFILTER = 0x29
sysMCAST_JOIN_GROUP = 0x2a
sysMCAST_LEAVE_GROUP = 0x2d
sysMCAST_JOIN_SOURCE_GROUP = 0x2e
sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
sysMCAST_BLOCK_SOURCE = 0x2b
sysMCAST_UNBLOCK_SOURCE = 0x2c
sysMCAST_MSFILTER = 0x30
sysIP_MULTICAST_ALL = 0x31 sysIP_MULTICAST_ALL = 0x31
sysIP_PMTUDISC_DONT = 0x0 sysIP_PMTUDISC_DONT = 0x0
...@@ -52,14 +60,30 @@ const ( ...@@ -52,14 +60,30 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSizeofKernelSockaddrStorage = 0x80
sysSizeofSockaddrInet = 0x10
sysSizeofInetPktinfo = 0xc sysSizeofInetPktinfo = 0xc
sysSizeofSockExtendedErr = 0x10 sysSizeofSockExtendedErr = 0x10
sysSizeofIPMreq = 0x8 sysSizeofIPMreq = 0x8
sysSizeofIPMreqn = 0xc sysSizeofIPMreqn = 0xc
sysSizeofIPMreqSource = 0xc sysSizeofIPMreqSource = 0xc
sysSizeofGroupReq = 0x88
sysSizeofGroupSourceReq = 0x108
) )
type sysKernelSockaddrStorage struct {
Family uint16
X__data [126]int8
}
type sysSockaddrInet struct {
Family uint16
Port uint16
Addr [4]byte /* in_addr */
X__pad [8]uint8
}
type sysInetPktinfo struct { type sysInetPktinfo struct {
Ifindex int32 Ifindex int32
Spec_dst [4]byte /* in_addr */ Spec_dst [4]byte /* in_addr */
...@@ -92,3 +116,16 @@ type sysIPMreqSource struct { ...@@ -92,3 +116,16 @@ type sysIPMreqSource struct {
Interface uint32 Interface uint32
Sourceaddr uint32 Sourceaddr uint32
} }
type sysGroupReq struct {
Interface uint32
Pad_cgo_0 [4]byte
Group sysKernelSockaddrStorage
}
type sysGroupSourceReq struct {
Interface uint32
Pad_cgo_0 [4]byte
Group sysKernelSockaddrStorage
Source sysKernelSockaddrStorage
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment