{"modulePath":"code.cloudfoundry.org/cli","version":"v6.1.1+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package ipv6\n\nPackage ipv6 implements IP-level socket options for the Internet Protocol version 6.\n\nThe package provides IP-level socket options that allow manipulation of IPv6 facilities.  The IPv6 and socket options for IPv6 are defined in RFC 2460, RFC 3493 and RFC 3542.\n\n### Unicasting {#hdr-Unicasting}\n\nThe options for unicasting are available for net.TCPConn, net.UDPConn and net.IPConn which are created as network connections that use the IPv6 transport.  When a single TCP connection carrying a data flow of multiple packets needs to indicate the flow is important, ipv6.Conn is used to set the traffic class field on the IPv6 header for each packet.\n\n\tln, err := net.Listen(\"tcp6\", \"[::]:1024\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\tdefer ln.Close()\n\tfor {\n\t\tc, err := ln.Accept()\n\t\tif err != nil {\n\t\t\t// error handling\n\t\t}\n\t\tgo func(c net.Conn) {\n\t\t\tdefer c.Close()\n\nThe outgoing packets will be labeled DiffServ assured forwarding class 1 low drop precedence, as known as AF11 packets.\n\n\t\t\tif err := ipv6.NewConn(c).SetTrafficClass(DiffServAF11); err != nil {\n\t\t\t\t// error handling\n\t\t\t}\n\t\t\tif _, err := c.Write(data); err != nil {\n\t\t\t\t// error handling\n\t\t\t}\n\t\t}(c)\n\t}\n\n### Multicasting {#hdr-Multicasting}\n\nThe options for multicasting are available for net.UDPConn and net.IPconn which are created as network connections that use the IPv6 transport.  A few network facilities must be prepared before you begin multicasting, at a minimum joining network interfaces and multicast groups.\n\n\ten0, err := net.InterfaceByName(\"en0\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\ten1, err := net.InterfaceByIndex(911)\n\tif err != nil {\n\t\t// error handling\n\t}\n\tgroup := net.ParseIP(\"ff02::114\")\n\nFirst, an application listens to an appropriate address with an appropriate service port.\n\n\tc, err := net.ListenPacket(\"udp6\", \"[::]:1024\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\tdefer c.Close()\n\nSecond, the application joins multicast groups, starts listening to the groups on the specified network interfaces.  Note that the service port for transport layer protocol does not matter with this operation as joining groups affects only network and link layer protocols, such as IPv6 and Ethernet.\n\n\tp := ipv6.NewPacketConn(c)\n\tif err := p.JoinGroup(en0, \u0026net.UDPAddr{IP: group}); err != nil {\n\t\t// error handling\n\t}\n\tif err := p.JoinGroup(en1, \u0026net.UDPAddr{IP: group}); err != nil {\n\t\t// error handling\n\t}\n\nThe application might set per packet control message transmissions between the protocol stack within the kernel.  When the application needs a destination address on an incoming packet, SetControlMessage of ipv6.PacketConn is used to enable control message transmissons.\n\n\tif err := p.SetControlMessage(ipv6.FlagDst, true); err != nil {\n\t\t// error handling\n\t}\n\nThe application could identify whether the received packets are of interest by using the control message that contains the destination address of the received packet.\n\n\tb := make([]byte, 1500)\n\tfor {\n\t\tn, rcm, src, err := p.ReadFrom(b)\n\t\tif err != nil {\n\t\t\t// error handling\n\t\t}\n\t\tif rcm.Dst.IsMulticast() {\n\t\t\tif rcm.Dst.Equal(group)\n\t\t\t\t// joined group, do something\n\t\t\t} else {\n\t\t\t\t// unknown group, discard\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\nThe application can also send both unicast and multicast packets.\n\n\t\tp.SetTrafficClass(DiffServCS0)\n\t\tp.SetHopLimit(16)\n\t\tif _, err := p.WriteTo(data[:n], nil, src); err != nil {\n\t\t\t// error handling\n\t\t}\n\t\tdst := \u0026net.UDPAddr{IP: group, Port: 1024}\n\t\twcm := ipv6.ControlMessage{TrafficClass: DiffServCS7, HopLimit: 1}\n\t\tfor _, ifi := range []*net.Interface{en0, en1} {\n\t\t\twcm.IfIndex = ifi.Index\n\t\t\tif _, err := p.WriteTo(data[:n], \u0026wcm, dst); err != nil {\n\t\t\t\t// error handling\n\t\t\t}\n\t\t}\n\t}\n\n### More multicasting {#hdr-More_multicasting}\n\nAn application that uses PacketConn may join multiple multicast groups.  For example, a UDP listener with port 1024 might join two different groups across over two different network interfaces by using:\n\n\tc, err := net.ListenPacket(\"udp6\", \"[::]:1024\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\tdefer c.Close()\n\tp := ipv6.NewPacketConn(c)\n\tif err := p.JoinGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::1:114\")}); err != nil {\n\t\t// error handling\n\t}\n\tif err := p.JoinGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::2:114\")}); err != nil {\n\t\t// error handling\n\t}\n\tif err := p.JoinGroup(en1, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::2:114\")}); err != nil {\n\t\t// error handling\n\t}\n\nIt is possible for multiple UDP listeners that listen on the same UDP port to join the same multicast group.  The net package will provide a socket that listens to a wildcard address with reusable UDP port when an appropriate multicast address prefix is passed to the net.ListenPacket or net.ListenUDP.\n\n\tc1, err := net.ListenPacket(\"udp6\", \"[ff02::]:1024\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\tdefer c1.Close()\n\tc2, err := net.ListenPacket(\"udp6\", \"[ff02::]:1024\")\n\tif err != nil {\n\t\t// error handling\n\t}\n\tdefer c2.Close()\n\tp1 := ipv6.NewPacketConn(c1)\n\tif err := p1.JoinGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::114\")}); err != nil {\n\t\t// error handling\n\t}\n\tp2 := ipv6.NewPacketConn(c2)\n\tif err := p2.JoinGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::114\")}); err != nil {\n\t\t// error handling\n\t}\n\nAlso it is possible for the application to leave or rejoin a multicast group on the network interface.\n\n\tif err := p.LeaveGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff02::114\")}); err != nil {\n\t\t// error handling\n\t}\n\tif err := p.JoinGroup(en0, \u0026net.UDPAddr{IP: net.ParseIP(\"ff01::114\")}); err != nil {\n\t\t// error handling\n\t}\n\n## Types\n\n```go\ntype Conn struct {\n\t// contains filtered or unexported fields\n}\n```\nA Conn represents a network endpoint that uses IPv6 transport. It allows to set basic IP-level socket options such as traffic class and hop limit.\n\n```go\nfunc NewConn(c net.Conn) *Conn\n```\nNewConn returns a new Conn.\n\n```go\nfunc (c *Conn) HopLimit() (int, error)\n```\nHopLimit returns the hop limit field value for outgoing packets.\n\n```go\nfunc (c *Conn) PathMTU() (int, error)\n```\nPathMTU returns a path MTU value for the destination associated with the endpoint.\n\n```go\nfunc (c *Conn) SetHopLimit(hoplim int) error\n```\nSetHopLimit sets the hop limit field value for future outgoing packets.\n\n```go\nfunc (c *Conn) SetTrafficClass(tclass int) error\n```\nSetTrafficClass sets the traffic class field value for future outgoing packets.\n\n```go\nfunc (c *Conn) TrafficClass() (int, error)\n```\nTrafficClass returns the traffic class field value for outgoing packets.\n\n```go\ntype ControlFlags uint\n```\nA ControlFlags reprensents per packet basis IP-level socket option control flags.\n\n```go\nconst (\n\tFlagTrafficClass ControlFlags = 1 \u003c\u003c iota // pass the traffic class on the received packet\n\tFlagHopLimit                              // pass the hop limit on the received packet\n\tFlagSrc                                   // pass the source address on the received packet\n\tFlagDst                                   // pass the destination address on the received packet\n\tFlagInterface                             // pass the interface index on the received packet\n\tFlagPathMTU                               // pass the path MTU on the received packet path\n)\n```\n\n```go\ntype ControlMessage struct {\n\t// Receiving socket options: SetControlMessage allows to\n\t// receive the options from the protocol stack using ReadFrom\n\t// method of PacketConn.\n\t//\n\t// Specifying socket options: ControlMessage for WriteTo\n\t// method of PacketConn allows to send the options to the\n\t// protocol stack.\n\t//\n\tTrafficClass int    // traffic class, must be 1 \u003c= value \u003c= 255 when specifying\n\tHopLimit     int    // hop limit, must be 1 \u003c= value \u003c= 255 when specifying\n\tSrc          net.IP // source address, specifying only\n\tDst          net.IP // destination address, receiving only\n\tIfIndex      int    // interface index, must be 1 \u003c= value when specifying\n\tNextHop      net.IP // next hop address, specifying only\n\tMTU          int    // path MTU, receiving only\n}\n```\nA ControlMessage represents per packet basis IP-level socket options.\n\n```go\nfunc (cm *ControlMessage) String() string\n```\n\n```go\ntype ICMPFilter struct {\n\t// contains filtered or unexported fields\n}\n```\nAn ICMPFilter represents an ICMP message filter for incoming packets.\n\n```go\nfunc (f *ICMPFilter) Set(typ ICMPType, block bool)\n```\nSet sets the ICMP type and filter action to the filter.\n\n```go\nfunc (f *ICMPFilter) SetAll(block bool)\n```\nSetAll sets the filter action to the filter.\n\n```go\nfunc (f *ICMPFilter) WillBlock(typ ICMPType) bool\n```\nWillBlock reports whether the ICMP type will be blocked.\n\n```go\ntype ICMPType int\n```\nAn ICMPType represents a type of ICMP message.\n\n```go\nconst (\n\tICMPTypeDestinationUnreachable                ICMPType = 1   // Destination Unreachable\n\tICMPTypePacketTooBig                          ICMPType = 2   // Packet Too Big\n\tICMPTypeTimeExceeded                          ICMPType = 3   // Time Exceeded\n\tICMPTypeParameterProblem                      ICMPType = 4   // Parameter Problem\n\tICMPTypeEchoRequest                           ICMPType = 128 // Echo Request\n\tICMPTypeEchoReply                             ICMPType = 129 // Echo Reply\n\tICMPTypeMulticastListenerQuery                ICMPType = 130 // Multicast Listener Query\n\tICMPTypeMulticastListenerReport               ICMPType = 131 // Multicast Listener Report\n\tICMPTypeMulticastListenerDone                 ICMPType = 132 // Multicast Listener Done\n\tICMPTypeRouterSolicitation                    ICMPType = 133 // Router Solicitation\n\tICMPTypeRouterAdvertisement                   ICMPType = 134 // Router Advertisement\n\tICMPTypeNeighborSolicitation                  ICMPType = 135 // Neighbor Solicitation\n\tICMPTypeNeighborAdvertisement                 ICMPType = 136 // Neighbor Advertisement\n\tICMPTypeRedirect                              ICMPType = 137 // Redirect Message\n\tICMPTypeRouterRenumbering                     ICMPType = 138 // Router Renumbering\n\tICMPTypeNodeInformationQuery                  ICMPType = 139 // ICMP Node Information Query\n\tICMPTypeNodeInformationResponse               ICMPType = 140 // ICMP Node Information Response\n\tICMPTypeInverseNeighborDiscoverySolicitation  ICMPType = 141 // Inverse Neighbor Discovery Solicitation Message\n\tICMPTypeInverseNeighborDiscoveryAdvertisement ICMPType = 142 // Inverse Neighbor Discovery Advertisement Message\n\tICMPTypeVersion2MulticastListenerReport       ICMPType = 143 // Version 2 Multicast Listener Report\n\tICMPTypeHomeAgentAddressDiscoveryRequest      ICMPType = 144 // Home Agent Address Discovery Request Message\n\tICMPTypeHomeAgentAddressDiscoveryReply        ICMPType = 145 // Home Agent Address Discovery Reply Message\n\tICMPTypeMobilePrefixSolicitation              ICMPType = 146 // Mobile Prefix Solicitation\n\tICMPTypeMobilePrefixAdvertisement             ICMPType = 147 // Mobile Prefix Advertisement\n\tICMPTypeCertificationPathSolicitation         ICMPType = 148 // Certification Path Solicitation Message\n\tICMPTypeCertificationPathAdvertisement        ICMPType = 149 // Certification Path Advertisement Message\n\tICMPTypeMulticastRouterAdvertisement          ICMPType = 151 // Multicast Router Advertisement\n\tICMPTypeMulticastRouterSolicitation           ICMPType = 152 // Multicast Router Solicitation\n\tICMPTypeMulticastRouterTermination            ICMPType = 153 // Multicast Router Termination\n\tICMPTypeFMIPv6                                ICMPType = 154 // FMIPv6 Messages\n\tICMPTypeRPLControl                            ICMPType = 155 // RPL Control Message\n\tICMPTypeILNPv6LocatorUpdate                   ICMPType = 156 // ILNPv6 Locator Update Message\n\tICMPTypeDuplicateAddressRequest               ICMPType = 157 // Duplicate Address Request\n\tICMPTypeDuplicateAddressConfirmation          ICMPType = 158 // Duplicate Address Confirmation\n)\n```\nInternet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2013-07-03\n\n```go\nfunc (typ ICMPType) String() string\n```\n\n```go\ntype PacketConn struct {\n\t// contains filtered or unexported fields\n}\n```\nA PacketConn represents a packet network endpoint that uses IPv6 transport.  It is used to control several IP-level socket options including IPv6 header manipulation.  It also provides datagram based network I/O methods specific to the IPv6 and higher layer protocols such as OSPF, GRE, and UDP.\n\n```go\nfunc NewPacketConn(c net.PacketConn) *PacketConn\n```\nNewPacketConn returns a new PacketConn using c as its underlying transport.\n\n```go\nfunc (c *PacketConn) Checksum() (on bool, offset int, err error)\n```\nChecksum 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.\n\n```go\nfunc (c *PacketConn) Close() error\n```\nClose closes the endpoint.\n\n```go\nfunc (c *PacketConn) HopLimit() (int, error)\n```\nHopLimit returns the hop limit field value for outgoing packets.\n\n```go\nfunc (c *PacketConn) ICMPFilter() (*ICMPFilter, error)\n```\nICMPFilter returns an ICMP filter.\n\n```go\nfunc (c *PacketConn) JoinGroup(ifi *net.Interface, group net.Addr) error\n```\nJoinGroup joins the group address group on the interface ifi. It 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.\n\n```go\nfunc (c *PacketConn) LeaveGroup(ifi *net.Interface, group net.Addr) error\n```\nLeaveGroup leaves the group address group on the interface ifi.\n\n```go\nfunc (c *PacketConn) MulticastHopLimit() (int, error)\n```\nMulticastHopLimit returns the hop limit field value for outgoing multicast packets.\n\n```go\nfunc (c *PacketConn) MulticastInterface() (*net.Interface, error)\n```\nMulticastInterface returns the default interface for multicast packet transmissions.\n\n```go\nfunc (c *PacketConn) MulticastLoopback() (bool, error)\n```\nMulticastLoopback reports whether transmitted multicast packets should be copied and send back to the originator.\n\n```go\nfunc (c *PacketConn) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error)\n```\nReadFrom reads a payload of the received IPv6 datagram, from the endpoint c, copying the payload into b.  It returns the number of bytes copied into b, the control message cm and the source address src of the received datagram.\n\n```go\nfunc (c *PacketConn) SetChecksum(on bool, offset int) error\n```\nSetChecksum enables the kernel checksum processing.  If on is ture, the offset should be an offset in bytes into the data of where the checksum field is located.\n\n```go\nfunc (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error\n```\nSetControlMessage allows to receive the per packet basis IP-level socket options.\n\n```go\nfunc (c *PacketConn) SetDeadline(t time.Time) error\n```\nSetDeadline sets the read and write deadlines associated with the endpoint.\n\n```go\nfunc (c *PacketConn) SetHopLimit(hoplim int) error\n```\nSetHopLimit sets the hop limit field value for future outgoing packets.\n\n```go\nfunc (c *PacketConn) SetICMPFilter(f *ICMPFilter) error\n```\nSetICMPFilter deploys the ICMP filter.\n\n```go\nfunc (c *PacketConn) SetMulticastHopLimit(hoplim int) error\n```\nSetMulticastHopLimit sets the hop limit field value for future outgoing multicast packets.\n\n```go\nfunc (c *PacketConn) SetMulticastInterface(ifi *net.Interface) error\n```\nSetMulticastInterface sets the default interface for future multicast packet transmissions.\n\n```go\nfunc (c *PacketConn) SetMulticastLoopback(on bool) error\n```\nSetMulticastLoopback sets whether transmitted multicast packets should be copied and send back to the originator.\n\n```go\nfunc (c *PacketConn) SetReadDeadline(t time.Time) error\n```\nSetReadDeadline sets the read deadline associated with the endpoint.\n\n```go\nfunc (c *PacketConn) SetTrafficClass(tclass int) error\n```\nSetTrafficClass sets the traffic class field value for future outgoing packets.\n\n```go\nfunc (c *PacketConn) SetWriteDeadline(t time.Time) error\n```\nSetWriteDeadline sets the write deadline associated with the endpoint.\n\n```go\nfunc (c *PacketConn) TrafficClass() (int, error)\n```\nTrafficClass returns the traffic class field value for outgoing packets.\n\n```go\nfunc (c *PacketConn) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error)\n```\nWriteTo writes a payload of the IPv6 datagram, to the destination address dst through the endpoint c, copying the payload from b.  It returns the number of bytes written.  The control message cm allows the IPv6 header fields and the datagram path to be specified.  The cm may be nil if control of the outgoing datagram is not required.\n\n","path":"code.cloudfoundry.org/cli/src/code.google.com/p/go.net/ipv6","name":"ipv6","synopsis":"Package ipv6 implements IP-level socket options for the Internet Protocol version 6.","isRedistributable":true}
