{
    "content": [
        {
            "type": "text",
            "text": "# IPV6 (man)\n\n## NAME\n\nipv6 - Linux IPv6 protocol implementation\n\n## DESCRIPTION\n\nLinux  2.2  optionally implements the Internet Protocol, version 6.  This man page contains a\ndescription of the IPv6 basic API as implemented by the Linux kernel and glibc 2.1.  The  in‐\nterface is based on the BSD sockets interface; see socket(7).\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS** (2 subsections)\n- **DESCRIPTION** (2 subsections)\n- **ERRORS**\n- **VERSIONS**\n- **NOTES**\n- **BUGS**\n- **SEE ALSO**\n- **COLOPHON**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "IPV6",
        "section": "",
        "mode": "man",
        "summary": "ipv6 - Linux IPv6 protocol implementation",
        "synopsis": "",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "cmsg",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/cmsg/3/json"
            },
            {
                "name": "ip",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/ip/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "#include <sys/socket.h>",
                        "lines": 1
                    },
                    {
                        "name": "#include <netinet/in.h>",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "DESCRIPTION",
                "lines": 22,
                "subsections": [
                    {
                        "name": "Address format",
                        "lines": 28
                    },
                    {
                        "name": "Socket options",
                        "lines": 84
                    }
                ]
            },
            {
                "name": "ERRORS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "VERSIONS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ipv6 - Linux IPv6 protocol implementation\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "",
                "subsections": [
                    {
                        "name": "#include <sys/socket.h>",
                        "content": ""
                    },
                    {
                        "name": "#include <netinet/in.h>",
                        "content": "tcp6socket = socket(AFINET6, SOCKSTREAM, 0);\nraw6socket = socket(AFINET6, SOCKRAW, protocol);\nudp6socket = socket(AFINET6, SOCKDGRAM, protocol);\n"
                    }
                ]
            },
            "DESCRIPTION": {
                "content": "Linux  2.2  optionally implements the Internet Protocol, version 6.  This man page contains a\ndescription of the IPv6 basic API as implemented by the Linux kernel and glibc 2.1.  The  in‐\nterface is based on the BSD sockets interface; see socket(7).\n\nThe  IPv6  API  aims to be mostly compatible with the IPv4 API (see ip(7)).  Only differences\nare described in this man page.\n\nTo bind an AFINET6 socket to any process, the  local  address  should  be  copied  from  the\nin6addrany  variable  which  has in6addr type.  In static initializations, IN6ADDRANYINIT\nmay also be used, which expands to a constant expression.  Both of them are in  network  byte\norder.\n\nThe  IPv6  loopback  address (::1) is available in the global in6addrloopback variable.  For\ninitializations, IN6ADDRLOOPBACKINIT should be used.\n\nIPv4 connections can be handled with the v6 API by using the  v4-mapped-on-v6  address  type;\nthus  a  program needs to support only this API type to support both protocols.  This is han‐\ndled transparently by the address handling functions in the C library.\n\nIPv4 and IPv6 share the local port space.  When you get an IPv4 connection or  packet  to  an\nIPv6 socket, its source address will be mapped to v6 and it will be mapped to v6.\n",
                "subsections": [
                    {
                        "name": "Address format",
                        "content": "struct sockaddrin6 {\nsafamilyt     sin6family;   /* AFINET6 */\ninportt       sin6port;     /* port number */\nuint32t        sin6flowinfo; /* IPv6 flow information */\nstruct in6addr sin6addr;     /* IPv6 address */\nuint32t        sin6scopeid; /* Scope ID (new in 2.4) */\n};\n\nstruct in6addr {\nunsigned char   s6addr[16];   /* IPv6 address */\n};\n\nsin6family  is  always  set  to  AFINET6;  sin6port  is the protocol port (see sinport in\nip(7)); sin6flowinfo is the IPv6 flow identifier; sin6addr is  the  128-bit  IPv6  address.\nsin6scopeid is an ID depending on the scope of the address.  It is new in Linux 2.4.  Linux\nsupports it only for link-local addresses, in that case sin6scopeid contains the  interface\nindex (see netdevice(7))\n\nIPv6 supports several address types: unicast to address a single host, multicast to address a\ngroup of hosts, anycast to address the nearest member of a group of hosts (not implemented in\nLinux), IPv4-on-IPv6 to address an IPv4 host, and other reserved address types.\n\nThe  address  notation for IPv6 is a group of 8 4-digit hexadecimal numbers, separated with a\n':'.  \"::\" stands for a string of 0  bits.   Special  addresses  are  ::1  for  loopback  and\n::FFFF:<IPv4 address> for IPv4-mapped-on-IPv6.\n\nThe port space of IPv6 is shared with IPv4.\n"
                    },
                    {
                        "name": "Socket options",
                        "content": "IPv6  supports  some  protocol-specific socket options that can be set with setsockopt(2) and\nread with getsockopt(2).  The socket option level for IPv6 is IPPROTOIPV6.  A boolean  inte‐\nger flag is zero when it is false, otherwise true.\n\nIPV6ADDRFORM\nTurn  an AFINET6 socket into a socket of a different address family.  Only AFINET is\ncurrently supported for that.  It is allowed only for IPv6 sockets that are  connected\nand  bound to a v4-mapped-on-v6 address.  The argument is a pointer to an integer con‐\ntaining AFINET.  This is useful to pass v4-mapped sockets as file descriptors to pro‐\ngrams that don't know how to deal with the IPv6 API.\n\nIPV6ADDMEMBERSHIP, IPV6DROPMEMBERSHIP\nControl membership in multicast groups.  Argument is a pointer to a struct ipv6mreq.\n\nIPV6MTU\ngetsockopt():  Retrieve  the current known path MTU of the current socket.  Valid only\nwhen the socket has been connected.  Returns an integer.\n\nsetsockopt(): Set the MTU to be used for the socket.  The MTU is limited by the device\nMTU  or the path MTU when path MTU discovery is enabled.  Argument is a pointer to in‐\nteger.\n\nIPV6MTUDISCOVER\nControl path-MTU discovery on the socket.  See IPMTUDISCOVER in ip(7) for details.\n\nIPV6MULTICASTHOPS\nSet the multicast hop limit for the socket.  Argument is a pointer to an integer.   -1\nin the value means use the route default, otherwise it should be between 0 and 255.\n\nIPV6MULTICASTIF\nSet the device for outgoing multicast packets on the socket.  This is allowed only for\nSOCKDGRAM and SOCKRAW socket.  The argument is a pointer to an interface index  (see\nnetdevice(7)) in an integer.\n\nIPV6MULTICASTLOOP\nControl  whether  the socket sees multicast packets that it has send itself.  Argument\nis a pointer to boolean.\n\nIPV6RECVPKTINFO (since Linux 2.6.14)\nSet delivery of the IPV6PKTINFO control message on incoming datagrams.  Such  control\nmessages  contain  a struct in6pktinfo, as per RFC 3542.  Allowed only for SOCKDGRAM\nor SOCKRAW sockets.  Argument is a pointer to a boolean value in an integer.\n\nIPV6RTHDR, IPV6AUTHHDR, IPV6DSTOPTS, IPV6HOPOPTS, IPV6FLOWINFO, IPV6HOPLIMIT\nSet delivery of control messages for incoming datagrams containing  extension  headers\nfrom the received packet.  IPV6RTHDR delivers the routing header, IPV6AUTHHDR deliv‐\ners  the  authentication  header,  IPV6DSTOPTS  delivers  the  destination   options,\nIPV6HOPOPTS  delivers  the  hop options, IPV6FLOWINFO delivers an integer containing\nthe flow ID, IPV6HOPLIMIT delivers an integer containing the hop count of the packet.\nThe  control  messages  have the same type as the socket option.  All these header op‐\ntions can also be set for outgoing packets by putting the appropriate control  message\ninto  the control buffer of sendmsg(2).  Allowed only for SOCKDGRAM or SOCKRAW sock‐\nets.  Argument is a pointer to a boolean value.\n\nIPV6RECVERR\nControl receiving of asynchronous error options.  See IPRECVERR in ip(7) for details.\nArgument is a pointer to boolean.\n\nIPV6ROUTERALERT\nPass  forwarded  packets  containing  a router alert hop-by-hop option to this socket.\nAllowed only for SOCKRAW sockets.  The tapped packets are not forwarded by  the  ker‐\nnel, it is the user's responsibility to send them out again.  Argument is a pointer to\nan integer.  A positive integer indicates a router alert option  value  to  intercept.\nPackets carrying a router alert option with a value field containing this integer will\nbe delivered to the socket.  A negative integer  disables  delivery  of  packets  with\nrouter alert options to this socket.\n\nIPV6UNICASTHOPS\nSet the unicast hop limit for the socket.  Argument is a pointer to an integer.  -1 in\nthe value means use the route default, otherwise it should be between 0 and 255.\n\nIPV6V6ONLY (since Linux 2.4.21 and 2.6)\nIf this flag is set to true (nonzero), then the socket is restricted  to  sending  and\nreceiving  IPv6  packets only.  In this case, an IPv4 and an IPv6 application can bind\nto a single port at the same time.\n\nIf this flag is set to false (zero), then the socket can be used to send  and  receive\npackets to and from an IPv6 address or an IPv4-mapped IPv6 address.\n\nThe argument is a pointer to a boolean value in an integer.\n\nThe   default   value   for  this  flag  is  defined  by  the  contents  of  the  file\n/proc/sys/net/ipv6/bindv6only.  The default value for that file is 0 (false).\n"
                    }
                ]
            },
            "ERRORS": {
                "content": "ENODEV The user tried to bind(2) to a link-local IPv6 address, but the sin6scopeid  in  the\nsupplied sockaddrin6 structure is not a valid interface index.\n",
                "subsections": []
            },
            "VERSIONS": {
                "content": "Linux  2.4  will break binary compatibility for the sockaddrin6 for 64-bit hosts by changing\nthe alignment of in6addr and adding an additional sin6scopeid field.   The  kernel  inter‐\nfaces stay compatible, but a program including sockaddrin6 or in6addr into other structures\nmay not be.  This is not a problem for 32-bit hosts like i386.\n\nThe sin6flowinfo field is new in Linux 2.4.  It is transparently passed/read by  the  kernel\nwhen  the passed address length contains it.  Some programs that pass a longer address buffer\nand then check the outgoing address length may break.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "The sockaddrin6 structure is bigger than the generic sockaddr.  Programs  that  assume  that\nall  address types can be stored safely in a struct sockaddr need to be changed to use struct\nsockaddrstorage for that instead.\n\nSOLIP, SOLIPV6, SOLICMPV6, and other SOL* socket options are nonportable variants of  IP‐‐\nPROTO*.  See also ip(7).\n",
                "subsections": []
            },
            "BUGS": {
                "content": "The  IPv6  extended API as in RFC 2292 is currently only partly implemented; although the 2.2\nkernel has near complete support for receiving options, the macros for  generating  IPv6  op‐\ntions are missing in glibc 2.1.\n\nIPSec support for EH and AH headers is missing.\n\nFlow label management is not complete and not documented here.\n\nThis man page is not complete.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "cmsg(3), ip(7)\n\nRFC 2553: IPv6 BASIC API; Linux tries to be compliant to this.  RFC 2460: IPv6 specification.\n",
                "subsections": []
            },
            "COLOPHON": {
                "content": "This  page  is  part  of  release  5.10 of the Linux man-pages project.  A description of the\nproject, information about reporting bugs, and the latest version of this page, can be  found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-12-21                                      IPV6(7)",
                "subsections": []
            }
        }
    }
}