Commit 66b3e5ee authored by Mikio Hara's avatar Mikio Hara

go.net/ipv6: make use of internal/iana package

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/166210043
parent 77ebfc57
......@@ -9,11 +9,13 @@ package ipv6
import (
"syscall"
"unsafe"
"code.google.com/p/go.net/internal/iana"
)
func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_2292HOPLIMIT
m.SetLen(syscall.CmsgLen(4))
if cm != nil {
......@@ -25,7 +27,7 @@ func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte {
func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_2292PKTINFO
m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo))
if cm != nil {
......@@ -42,7 +44,7 @@ func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte {
func marshal2292NextHop(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_2292NEXTHOP
m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6))
if cm != nil {
......
......@@ -9,11 +9,13 @@ package ipv6
import (
"syscall"
"unsafe"
"code.google.com/p/go.net/internal/iana"
)
func marshalTrafficClass(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_TCLASS
m.SetLen(syscall.CmsgLen(4))
if cm != nil {
......@@ -29,7 +31,7 @@ func parseTrafficClass(cm *ControlMessage, b []byte) {
func marshalHopLimit(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_HOPLIMIT
m.SetLen(syscall.CmsgLen(4))
if cm != nil {
......@@ -45,7 +47,7 @@ func parseHopLimit(cm *ControlMessage, b []byte) {
func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_PKTINFO
m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo))
if cm != nil {
......@@ -68,7 +70,7 @@ func parsePacketInfo(cm *ControlMessage, b []byte) {
func marshalNextHop(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_NEXTHOP
m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6))
if cm != nil {
......@@ -83,7 +85,7 @@ func parseNextHop(cm *ControlMessage, b []byte) {
func marshalPathMTU(b []byte, cm *ControlMessage) []byte {
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
m.Level = ianaProtocolIPv6
m.Level = iana.ProtocolIPv6
m.Type = sysIPV6_PATHMTU
m.SetLen(syscall.CmsgLen(sysSizeofIPv6Mtuinfo))
return b[syscall.CmsgSpace(sysSizeofIPv6Mtuinfo):]
......
......@@ -9,6 +9,8 @@ package ipv6
import (
"os"
"syscall"
"code.google.com/p/go.net/internal/iana"
)
func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
......@@ -102,7 +104,7 @@ func parseControlMessage(b []byte) (*ControlMessage, error) {
}
cm := &ControlMessage{}
for _, m := range cmsgs {
if m.Header.Level != ianaProtocolIPv6 {
if m.Header.Level != iana.ProtocolIPv6 {
continue
}
switch int(m.Header.Type) {
......
......@@ -9,6 +9,8 @@ package ipv6
import (
"net"
"syscall"
"code.google.com/p/go.net/internal/iana"
)
type sysSockoptLen int32
......@@ -22,20 +24,20 @@ var (
}
sockOpts = [ssoMax]sockOpt{
ssoTrafficClass: {ianaProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {ianaProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {ianaProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {ianaProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {ianaProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveTrafficClass: {ianaProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
ssoReceiveHopLimit: {ianaProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {ianaProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
ssoReceivePathMTU: {ianaProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
ssoPathMTU: {ianaProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
ssoChecksum: {ianaProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {ianaProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {ianaProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {ianaProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
}
)
......
......@@ -7,6 +7,8 @@ package ipv6
import (
"net"
"syscall"
"code.google.com/p/go.net/internal/iana"
)
type sysSockoptLen int32
......@@ -18,17 +20,17 @@ var (
}
sockOpts = [ssoMax]sockOpt{
ssoTrafficClass: {ianaProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {ianaProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {ianaProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {ianaProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {ianaProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveHopLimit: {ianaProtocolIPv6, sysIPV6_2292HOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {ianaProtocolIPv6, sysIPV6_2292PKTINFO, ssoTypeInt},
ssoChecksum: {ianaProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {ianaProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {ianaProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {ianaProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_2292HOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_2292PKTINFO, ssoTypeInt},
ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
}
)
......@@ -57,12 +59,12 @@ func init() {
ctlOpts[ctlHopLimit].marshal = marshalHopLimit
ctlOpts[ctlPacketInfo].name = sysIPV6_PKTINFO
ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo
sockOpts[ssoReceiveTrafficClass].level = ianaProtocolIPv6
sockOpts[ssoReceiveTrafficClass].level = iana.ProtocolIPv6
sockOpts[ssoReceiveTrafficClass].name = sysIPV6_RECVTCLASS
sockOpts[ssoReceiveTrafficClass].typ = ssoTypeInt
sockOpts[ssoReceiveHopLimit].name = sysIPV6_RECVHOPLIMIT
sockOpts[ssoReceivePacketInfo].name = sysIPV6_RECVPKTINFO
sockOpts[ssoReceivePathMTU].level = ianaProtocolIPv6
sockOpts[ssoReceivePathMTU].level = iana.ProtocolIPv6
sockOpts[ssoReceivePathMTU].name = sysIPV6_RECVPATHMTU
sockOpts[ssoReceivePathMTU].typ = ssoTypeInt
}
......
......@@ -7,6 +7,8 @@ package ipv6
import (
"net"
"syscall"
"code.google.com/p/go.net/internal/iana"
)
type sysSockoptLen int32
......@@ -19,20 +21,20 @@ var (
}
sockOpts = [ssoMax]sockOpt{
ssoTrafficClass: {ianaProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {ianaProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {ianaProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {ianaProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {ianaProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveTrafficClass: {ianaProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
ssoReceiveHopLimit: {ianaProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {ianaProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
ssoReceivePathMTU: {ianaProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
ssoPathMTU: {ianaProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
ssoChecksum: {ianaProtocolReserved, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {ianaProtocolIPv6ICMP, sysICMPV6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {ianaProtocolIPv6, sysIPV6_ADD_MEMBERSHIP, ssoTypeIPMreq},
ssoLeaveGroup: {ianaProtocolIPv6, sysIPV6_DROP_MEMBERSHIP, ssoTypeIPMreq},
ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
ssoChecksum: {iana.ProtocolReserved, sysIPV6_CHECKSUM, ssoTypeInt},
ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMPV6_FILTER, ssoTypeICMPFilter},
ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_ADD_MEMBERSHIP, ssoTypeIPMreq},
ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_DROP_MEMBERSHIP, ssoTypeIPMreq},
}
)
......
......@@ -7,6 +7,8 @@ package ipv6
import (
"net"
"syscall"
"code.google.com/p/go.net/internal/iana"
)
const (
......@@ -41,12 +43,12 @@ var (
ctlOpts = [ctlMax]ctlOpt{}
sockOpts = [ssoMax]sockOpt{
ssoHopLimit: {ianaProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {ianaProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {ianaProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {ianaProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoJoinGroup: {ianaProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {ianaProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
}
)
......
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