Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > I

IPv6(7P)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

IPv6, ipv6, ip6 — Internet Protocol Version 6

SYNOPSIS

#include <sys/socket.h> #include <netinet/in.h> s = socket(AF_INET6, SOCK_DGRAM, 0); s = socket(AF_INET6, SOCK_STREAM, 0);

DESCRIPTION

IPv6 is the next generation network-layer protocol designed to be the successor to the current Internet Protocol version 4 (IPv4). It provides the packet delivery service for TCP, UDP and ICMPv6.

IPv6 has significant advantages over IPv4 in terms of increased address space, simplified header format, integrated QoS support and mandatory security. IPv6 also allows optional internet-layer information to be encoded in separate headers called extension headers which are placed between the IPv6 header and upper layer headers. Extension headers currently supported are hop-by-hop option header, destination option header, fragment header and routing (type 0) header. An IPv6 packet may carry zero, one, or more extension headers, each identified by the next header field of the preceding header.

IPv6 has extended the address size from 32 bits to 128 bits and they are textually represented in hex-colon notation as x:x:x:x:x:x:x:x, where the x's are the hexadecimal values of the eight 16-bit pieces of the address. For example fedc:83ff:fef6:417a:210:83ff:fef6:3dc0.

IPv6 has three types of addresses: unicast, anycast, and multicast.

  • An unicast address is an identifier for a single interface. A packet sent to an unicast address is delivered to the interface identified by that address.

  • An anycast address is an identifier for a set of interfaces. A packet sent to an anycast address is delivered to one of the interfaces identified by that address.

  • A multicast address is an identifier for a set of interfaces. A packet sent to a multicast address is delivered to all interfaces identified by that address.

    There are no broadcast addresses in IPv6, their function is superseded by multicast addresses.

Every IPv6 address has a scope associated with it. A scope is a topological span within which the address may be used as an unique identifier for an interface or set of interfaces.

An unicast address has three defined scopes: link-local, site-local and global.

  • Link-local address uniquely identifies interfaces within a single link and it has a fixed prefix of fe80::/10. For example, fe80::210:84c0:ef6f:cd30.

  • Site-local address uniquely identifies interfaces within a single site only and it has a fixed prefix of fec0::/10. For example, fec0::210:84c0:ef6f:cd30.

  • Global address uniquely identifies interfaces anywhere in the internet.

There are 2 special unicast addresses which hold an embedded IPv4 address in the low order 32-bits.

  • The first type is termed as IPv4-compatible IPv6 address and is of the form 0:0:0:0:0:0:d.d.d.d. This type of address is used by dual stack (IPv4/IPv6) nodes to perform automatic IPv6-over-IPv4 tunneling where the IPv4 tunnel endpoint address is determined from the IPv4 address embedded in the IPv4-compatible destination address of the IPv6 packet being tunneled.

  • The second type is termed as IPv4-mapped IPv6 address and is of the form 0:0:0:0:0:ffff:d.d.d.d. This address facilitates IPv6 applications to interoperate with IPv4 applications. Applications can automatically generate this address using getaddrinfo() (see getaddrinfo(3N)) when the specified host has only IPv4 address.

IPv6 Socket Options

New socket options are defined for IPv6 to send and receive extension headers and to exchange other optional information between the kernel and application. The options are supported at the IPPROTO_IPV6 protocol level. The type of the variable pointed to by the optval parameter is indicated in parenthesis.

IPV6_UNICAST_HOPS

(integer) Set or get the hop limit used in outgoing unicast packets. When this option is set using setsockopt()(see setsockopt(2)), the new option value specified is used as the hop limit for all subsequent unicast packets sent via that socket. Valid values are in the range 0-255 (both inclusive) and the default value is 64. For example,

int hoplimit = 50; setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &hoplimit, sizeof(hoplimit));

This option can be used with getsockopt() (see getsockopt(2)) to determine the hop limit value the system will use for subsequent unicast packets sent via that socket.

IPV6_MULTICAST_HOPS

(integer) Set or get the hop limit used in outgoing multicast packets. When this option is set, the new option value specified is used as the hop limit for all subsequent multicast packets sent via that socket. Valid values are in the range 0-255 (both inclusive) and the default value is 1.

IPV6_MULTICAST_IF

(integer) Sets the interface to use for outgoing multicast packets. The option value is the index of the selected outgoing interface. For example,

unsigned int index; index = if_nametoindex("lan0"); setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &index, sizeof(index));

IPV6_MULTICAST_LOOP

(boolean) Enables or disables loopback in the IP layer for multicast datagrams sent through this socket. The value of the variable pointed to by optval is zero (disable) or non-zero (enable). Default: enabled.

IPV6_JOIN_GROUP

(struct ipv6_mreq) Join a multicast group on a specified local interface. The IPv6 multicast address of the group to join and the index of the interface on which to join should be specified using struct ipv6_mreq which is defined in <netinet/in6.h> as:

struct ipv6_mreq { struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */ unsigned int ipv6mr_interface; /* interface index */ };

If the interface index is specified as 0 then the default multicast interface is used.

IPV6_LEAVE_GROUP

(struct ipv6_mreq) Leave a multicast group on a specified local interface. The IPv6 multicast address of the group to leave and the interface index should be specified using struct ipv6_mreq. The interface index should match the index used while joining the group. Set index to 0, to specify default interface.

IPV6_CHECKSUM

(integer) When this option is set, kernel computes the checksum for outbound packets and verifies checksum on inbound packets. The option value is the byte offset of the checksum location in the user data. This option is not valid for IPPROTO_ICMPV6 since checksum computation is mandatory for IPPROTO_ICMPV6. The default value is -1 (checksums not computed nor verified for protocols other than IPPROTO_ICMPV6).

IPV6_RECVPKTINFO

(boolean) When this option is enabled, PKTINFO (destination IPv6 address and the arriving interface index) is returned as ancillary data by recvmsg(). (See recvmsg(2)). The information is returned in struct in6_pktinfo structure and it is defined in <netinet/in6.h>as:

struct in6_pktinfo { struct in6_addr ipi6_addr; uint32_t ipi6_ifindex; };

By default this option is disabled.

IPV6_RECVHOPLIMIT

(boolean) When this option is enabled, inbound packet's hoplimit is returned as ancillary data by recvmsg(). For example,

int on = 1; setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on));

By default this option is disabled.

IPV6_RECVDSTOPTS

(boolean) When this option is enabled, the inbound packet's destination options (when present) is returned as ancillary data by recvmsg(). By default this option is disabled.

IPV6_RECVHOPOPTS

(boolean) When this option is enabled, the inbound packet's hop-by-hop options (when present) is returned as ancillary data by recvmsg(). By default this option is disabled.

IPV6_RECVRTHDR

(integer; boolean) When this option is enabled, the inbound packet's routing options (when present) is returned as ancillary data by recvmsg(). By default this option is disabled.

IPV6_RECVRTHDRDSTOPTS

(integer; boolean) When this option is enabled, the inbound packet's destination options appearing before a routing header (when present) is returned as ancillary data by recvmsg(). By default this option is disabled.

The next seven socket options can be used with both setsockopt() and as option name in ancillary data to sendmsg(). (See sendmsg(2))

IPV6_PKTINFO

(struct in6_pktinfo) Used to set the source address and interface index for outgoing packets.

IPV6_HOPLIMIT

(integer) Used to set the hop limit for outbound packets. This hop limit is valid for only a single output operation. To set hop limit for all unicast or multicast IPv6 packets use IPV6_UNICAST_HOPS or IPV6_MULTICAST_HOPS options respectively.

IPV6_NEXTHOP

(struct sockaddr_in6) Used to set the next hop address. The node identified by this address must be a neighbor of the sending host. When this address is the same as the destination IPv6 address then this is equivalent to SO_DONTROUTE socket option.

IPV6_RTHDR

(variable length) Used to specify the routing header for outgoing packets. Only Type 0 routing header is currently supported.

IPV6_DSTOPTS

(variable length) Used to specify one or more destination options to be sent in subsequent IPv6 packets.

IPV6_HOPOPTS

(variable length) Used to specify one or more hop-by-hop options to be sent in subsequent IPv6 packets.

IPV6_RTHDRDSTOPTS

(variable length) Used to specify one or more destination options preceding a routing header. This option will be silently ignored when sending packets unless a routing header is also specified.

IPv6 uses the enhanced version of ICMP called ICMPv6 to report errors encountered in processing packets and for diagnostic purposes (like ping). ICMPv6 is an integral part of IPv6 and has a next header value of 58.

All the options and the associated structures are defined in <netinet/in6.h>, applications are not required to include this header file explicitly, it is automatically included by <netinet/in.h>.

ERRORS

One of the following errors may be returned when a socket operation fails.

EADDRINUSE

The specified multicast group has been joined already.

EADDRNOTAVAIL

The specified IPv6 address is not a local interface address or there is no route for the specified multicast address or the specified multicast group has not been joined.

EINVAL

The parameter 'level' is not IPPROTO_IPV6, or optval is the NULL address, or the specified multicast address is not valid, or the specified hop limit is not in the range 0 <= x<= 255.

ENOBUFS

Insufficient memory is available for internal system data structures.

ENOPROTOOPT

The parameter optname is not a valid socket option for the IPPROTO_IPV6 level.

AUTHOR

The socket interfaces to IP were developed by the University of California, Berkeley.

SEE ALSO

bind(2), getsockopt(2), recv(2), send(2), socket(2), inet6_opt_init(3N), inet6_rth_space(3N), inet(7F), ndp(7P).

RFC 2460 Internet Protocol Version 6.

RFC 2553 Basic Socket Interface Extensions for IPv6.

RFC 2292 Advanced Socket Interface Extensions for IPv6.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.