2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Types and definitions for AF_INET6
|
|
|
|
* Linux INET6 implementation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Pedro Roque <roque@di.fc.ul.pt>
|
|
|
|
*
|
|
|
|
* Sources:
|
|
|
|
* IPv6 Program Interfaces for BSD Systems
|
|
|
|
* <draft-ietf-ipngwg-bsd-api-05.txt>
|
|
|
|
*
|
|
|
|
* Advanced Sockets API for IPv6
|
|
|
|
* <draft-stevens-advanced-api-00.txt>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_IN6_H
|
|
|
|
#define _LINUX_IN6_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IPv6 address structure
|
|
|
|
*/
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct in6_addr {
|
|
|
|
union {
|
2005-04-17 06:20:36 +08:00
|
|
|
__u8 u6_addr8[16];
|
2006-09-28 09:44:54 +08:00
|
|
|
__be16 u6_addr16[8];
|
|
|
|
__be32 u6_addr32[4];
|
2005-04-17 06:20:36 +08:00
|
|
|
} in6_u;
|
|
|
|
#define s6_addr in6_u.u6_addr8
|
|
|
|
#define s6_addr16 in6_u.u6_addr16
|
|
|
|
#define s6_addr32 in6_u.u6_addr32
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IPv6 Wildcard Address (::) and Loopback Address (::1) defined in RFC2553
|
|
|
|
* NOTE: Be aware the IN6ADDR_* constants and in6addr_* externals are defined
|
|
|
|
* in network byte order, not in host byte order as are the IPv4 equivalents
|
|
|
|
*/
|
2009-02-03 00:10:58 +08:00
|
|
|
#ifdef __KERNEL__
|
2005-04-17 06:20:36 +08:00
|
|
|
extern const struct in6_addr in6addr_any;
|
|
|
|
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
|
|
|
extern const struct in6_addr in6addr_loopback;
|
|
|
|
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
2008-04-10 14:42:11 +08:00
|
|
|
extern const struct in6_addr in6addr_linklocal_allnodes;
|
|
|
|
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
|
|
|
|
{ { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
|
|
|
extern const struct in6_addr in6addr_linklocal_allrouters;
|
|
|
|
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
|
|
|
|
{ { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } }
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct sockaddr_in6 {
|
|
|
|
unsigned short int sin6_family; /* AF_INET6 */
|
2006-09-28 09:45:27 +08:00
|
|
|
__be16 sin6_port; /* Transport layer port # */
|
2006-11-08 16:25:17 +08:00
|
|
|
__be32 sin6_flowinfo; /* IPv6 flow information */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct in6_addr sin6_addr; /* IPv6 address */
|
|
|
|
__u32 sin6_scope_id; /* scope id (new in RFC2553) */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ipv6_mreq {
|
|
|
|
/* IPv6 multicast address of group */
|
|
|
|
struct in6_addr ipv6mr_multiaddr;
|
|
|
|
|
|
|
|
/* local IPv6 address of interface */
|
|
|
|
int ipv6mr_ifindex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ipv6mr_acaddr ipv6mr_multiaddr
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct in6_flowlabel_req {
|
2005-04-17 06:20:36 +08:00
|
|
|
struct in6_addr flr_dst;
|
2006-11-08 16:25:17 +08:00
|
|
|
__be32 flr_label;
|
2005-04-17 06:20:36 +08:00
|
|
|
__u8 flr_action;
|
|
|
|
__u8 flr_share;
|
|
|
|
__u16 flr_flags;
|
|
|
|
__u16 flr_expires;
|
|
|
|
__u16 flr_linger;
|
|
|
|
__u32 __flr_pad;
|
|
|
|
/* Options in format of IPV6_PKTOPTIONS */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IPV6_FL_A_GET 0
|
|
|
|
#define IPV6_FL_A_PUT 1
|
|
|
|
#define IPV6_FL_A_RENEW 2
|
|
|
|
|
|
|
|
#define IPV6_FL_F_CREATE 1
|
|
|
|
#define IPV6_FL_F_EXCL 2
|
|
|
|
|
|
|
|
#define IPV6_FL_S_NONE 0
|
|
|
|
#define IPV6_FL_S_EXCL 1
|
|
|
|
#define IPV6_FL_S_PROCESS 2
|
|
|
|
#define IPV6_FL_S_USER 3
|
|
|
|
#define IPV6_FL_S_ANY 255
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bitmask constant declarations to help applications select out the
|
|
|
|
* flow label and priority fields.
|
|
|
|
*
|
|
|
|
* Note that this are in host byte order while the flowinfo field of
|
|
|
|
* sockaddr_in6 is in network byte order.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IPV6_FLOWINFO_FLOWLABEL 0x000fffff
|
|
|
|
#define IPV6_FLOWINFO_PRIORITY 0x0ff00000
|
|
|
|
|
2009-12-05 04:47:01 +08:00
|
|
|
/* These definitions are obsolete */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define IPV6_PRIORITY_UNCHARACTERIZED 0x0000
|
|
|
|
#define IPV6_PRIORITY_FILLER 0x0100
|
|
|
|
#define IPV6_PRIORITY_UNATTENDED 0x0200
|
|
|
|
#define IPV6_PRIORITY_RESERVED1 0x0300
|
|
|
|
#define IPV6_PRIORITY_BULK 0x0400
|
|
|
|
#define IPV6_PRIORITY_RESERVED2 0x0500
|
|
|
|
#define IPV6_PRIORITY_INTERACTIVE 0x0600
|
|
|
|
#define IPV6_PRIORITY_CONTROL 0x0700
|
|
|
|
#define IPV6_PRIORITY_8 0x0800
|
|
|
|
#define IPV6_PRIORITY_9 0x0900
|
|
|
|
#define IPV6_PRIORITY_10 0x0a00
|
|
|
|
#define IPV6_PRIORITY_11 0x0b00
|
|
|
|
#define IPV6_PRIORITY_12 0x0c00
|
|
|
|
#define IPV6_PRIORITY_13 0x0d00
|
|
|
|
#define IPV6_PRIORITY_14 0x0e00
|
|
|
|
#define IPV6_PRIORITY_15 0x0f00
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IPV6 extension headers
|
|
|
|
*/
|
|
|
|
#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
|
|
|
|
#define IPPROTO_ROUTING 43 /* IPv6 routing header */
|
|
|
|
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
|
|
|
|
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
|
|
|
#define IPPROTO_NONE 59 /* IPv6 no next header */
|
|
|
|
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
|
2006-08-24 11:34:26 +08:00
|
|
|
#define IPPROTO_MH 135 /* IPv6 mobility header */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IPv6 TLV options.
|
|
|
|
*/
|
|
|
|
#define IPV6_TLV_PAD0 0
|
|
|
|
#define IPV6_TLV_PADN 1
|
|
|
|
#define IPV6_TLV_ROUTERALERT 5
|
|
|
|
#define IPV6_TLV_JUMBO 194
|
2006-08-24 10:21:34 +08:00
|
|
|
#define IPV6_TLV_HAO 201 /* home address option */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IPV6 socket options
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IPV6_ADDRFORM 1
|
[IPV6]: Support several new sockopt / ancillary data in Advanced API (RFC3542).
Support several new socket options / ancillary data:
IPV6_RECVPKTINFO, IPV6_PKTINFO,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS,
IPV6_RECVDSTOPTS, IPV6_DSTOPTS, IPV6_RTHDRDSTOPTS,
IPV6_RECVRTHDR, IPV6_RTHDR,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS
Old semantics are preserved as IPV6_2292xxxx so that
we can maintain backward compatibility.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2005-09-08 08:59:17 +08:00
|
|
|
#define IPV6_2292PKTINFO 2
|
|
|
|
#define IPV6_2292HOPOPTS 3
|
|
|
|
#define IPV6_2292DSTOPTS 4
|
|
|
|
#define IPV6_2292RTHDR 5
|
|
|
|
#define IPV6_2292PKTOPTIONS 6
|
2005-04-17 06:20:36 +08:00
|
|
|
#define IPV6_CHECKSUM 7
|
[IPV6]: Support several new sockopt / ancillary data in Advanced API (RFC3542).
Support several new socket options / ancillary data:
IPV6_RECVPKTINFO, IPV6_PKTINFO,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS,
IPV6_RECVDSTOPTS, IPV6_DSTOPTS, IPV6_RTHDRDSTOPTS,
IPV6_RECVRTHDR, IPV6_RTHDR,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS
Old semantics are preserved as IPV6_2292xxxx so that
we can maintain backward compatibility.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2005-09-08 08:59:17 +08:00
|
|
|
#define IPV6_2292HOPLIMIT 8
|
2005-04-17 06:20:36 +08:00
|
|
|
#define IPV6_NEXTHOP 9
|
2005-06-29 06:46:24 +08:00
|
|
|
#define IPV6_AUTHHDR 10 /* obsolete */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define IPV6_FLOWINFO 11
|
|
|
|
|
|
|
|
#define IPV6_UNICAST_HOPS 16
|
|
|
|
#define IPV6_MULTICAST_IF 17
|
|
|
|
#define IPV6_MULTICAST_HOPS 18
|
|
|
|
#define IPV6_MULTICAST_LOOP 19
|
|
|
|
#define IPV6_ADD_MEMBERSHIP 20
|
|
|
|
#define IPV6_DROP_MEMBERSHIP 21
|
|
|
|
#define IPV6_ROUTER_ALERT 22
|
|
|
|
#define IPV6_MTU_DISCOVER 23
|
|
|
|
#define IPV6_MTU 24
|
|
|
|
#define IPV6_RECVERR 25
|
|
|
|
#define IPV6_V6ONLY 26
|
|
|
|
#define IPV6_JOIN_ANYCAST 27
|
|
|
|
#define IPV6_LEAVE_ANYCAST 28
|
|
|
|
|
|
|
|
/* IPV6_MTU_DISCOVER values */
|
|
|
|
#define IPV6_PMTUDISC_DONT 0
|
|
|
|
#define IPV6_PMTUDISC_WANT 1
|
|
|
|
#define IPV6_PMTUDISC_DO 2
|
2007-04-21 06:53:27 +08:00
|
|
|
#define IPV6_PMTUDISC_PROBE 3
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Flowlabel */
|
|
|
|
#define IPV6_FLOWLABEL_MGR 32
|
|
|
|
#define IPV6_FLOWINFO_SEND 33
|
|
|
|
|
|
|
|
#define IPV6_IPSEC_POLICY 34
|
|
|
|
#define IPV6_XFRM_POLICY 35
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Multicast:
|
|
|
|
* Following socket options are shared between IPv4 and IPv6.
|
|
|
|
*
|
|
|
|
* MCAST_JOIN_GROUP 42
|
|
|
|
* MCAST_BLOCK_SOURCE 43
|
|
|
|
* MCAST_UNBLOCK_SOURCE 44
|
|
|
|
* MCAST_LEAVE_GROUP 45
|
|
|
|
* MCAST_JOIN_SOURCE_GROUP 46
|
|
|
|
* MCAST_LEAVE_SOURCE_GROUP 47
|
|
|
|
* MCAST_MSFILTER 48
|
|
|
|
*/
|
|
|
|
|
2005-09-10 10:26:34 +08:00
|
|
|
/*
|
|
|
|
* Advanced API (RFC3542) (1)
|
|
|
|
*
|
|
|
|
* Note: IPV6_RECVRTHDRDSTOPTS does not exist. see net/ipv6/datagram.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IPV6_RECVPKTINFO 49
|
|
|
|
#define IPV6_PKTINFO 50
|
|
|
|
#define IPV6_RECVHOPLIMIT 51
|
|
|
|
#define IPV6_HOPLIMIT 52
|
|
|
|
#define IPV6_RECVHOPOPTS 53
|
|
|
|
#define IPV6_HOPOPTS 54
|
|
|
|
#define IPV6_RTHDRDSTOPTS 55
|
|
|
|
#define IPV6_RECVRTHDR 56
|
|
|
|
#define IPV6_RTHDR 57
|
|
|
|
#define IPV6_RECVDSTOPTS 58
|
|
|
|
#define IPV6_DSTOPTS 59
|
|
|
|
#define IPV6_RECVPATHMTU 60
|
|
|
|
#define IPV6_PATHMTU 61
|
|
|
|
#define IPV6_DONTFRAG 62
|
2010-04-23 19:26:07 +08:00
|
|
|
#if 0 /* not yet */
|
2005-09-10 10:26:34 +08:00
|
|
|
#define IPV6_USE_MIN_MTU 63
|
[IPV6]: Support several new sockopt / ancillary data in Advanced API (RFC3542).
Support several new socket options / ancillary data:
IPV6_RECVPKTINFO, IPV6_PKTINFO,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS,
IPV6_RECVDSTOPTS, IPV6_DSTOPTS, IPV6_RTHDRDSTOPTS,
IPV6_RECVRTHDR, IPV6_RTHDR,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS
Old semantics are preserved as IPV6_2292xxxx so that
we can maintain backward compatibility.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2005-09-08 08:59:17 +08:00
|
|
|
#endif
|
2005-09-10 10:32:45 +08:00
|
|
|
|
|
|
|
/*
|
2006-11-15 11:48:48 +08:00
|
|
|
* Netfilter (1)
|
2005-09-10 10:32:45 +08:00
|
|
|
*
|
|
|
|
* Following socket options are used in ip6_tables;
|
|
|
|
* see include/linux/netfilter_ipv6/ip6_tables.h.
|
|
|
|
*
|
|
|
|
* IP6T_SO_SET_REPLACE / IP6T_SO_GET_INFO 64
|
|
|
|
* IP6T_SO_SET_ADD_COUNTERS / IP6T_SO_GET_ENTRIES 65
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advanced API (RFC3542) (2)
|
|
|
|
*/
|
[IPV6]: Support several new sockopt / ancillary data in Advanced API (RFC3542).
Support several new socket options / ancillary data:
IPV6_RECVPKTINFO, IPV6_PKTINFO,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS,
IPV6_RECVDSTOPTS, IPV6_DSTOPTS, IPV6_RTHDRDSTOPTS,
IPV6_RECVRTHDR, IPV6_RTHDR,
IPV6_RECVHOPOPTS, IPV6_HOPOPTS
Old semantics are preserved as IPV6_2292xxxx so that
we can maintain backward compatibility.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2005-09-08 08:59:17 +08:00
|
|
|
#define IPV6_RECVTCLASS 66
|
|
|
|
#define IPV6_TCLASS 67
|
|
|
|
|
2006-11-15 11:48:48 +08:00
|
|
|
/*
|
|
|
|
* Netfilter (2)
|
|
|
|
*
|
|
|
|
* Following socket options are used in ip6_tables;
|
|
|
|
* see include/linux/netfilter_ipv6/ip6_tables.h.
|
|
|
|
*
|
|
|
|
* IP6T_SO_GET_REVISION_MATCH 68
|
|
|
|
* IP6T_SO_GET_REVISION_TARGET 69
|
|
|
|
*/
|
|
|
|
|
2008-03-25 08:37:42 +08:00
|
|
|
/* RFC5014: Source address selection */
|
|
|
|
#define IPV6_ADDR_PREFERENCES 72
|
|
|
|
|
|
|
|
#define IPV6_PREFER_SRC_TMP 0x0001
|
|
|
|
#define IPV6_PREFER_SRC_PUBLIC 0x0002
|
|
|
|
#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
|
|
|
|
#define IPV6_PREFER_SRC_COA 0x0004
|
|
|
|
#define IPV6_PREFER_SRC_HOME 0x0400
|
|
|
|
#define IPV6_PREFER_SRC_CGA 0x0008
|
|
|
|
#define IPV6_PREFER_SRC_NONCGA 0x0800
|
|
|
|
|
IPv6: Generic TTL Security Mechanism (final version)
This patch adds IPv6 support for RFC5082 Generalized TTL Security Mechanism.
Not to users of mapped address; the IPV6 and IPV4 socket options are seperate.
The server does have to deal with both IPv4 and IPv6 socket options
and the client has to handle the different for each family.
On client:
int ttl = 255;
getaddrinfo(argv[1], argv[2], &hint, &result);
for (rp = result; rp != NULL; rp = rp->ai_next) {
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (s < 0) continue;
if (rp->ai_family == AF_INET) {
setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
} else if (rp->ai_family == AF_INET6) {
setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
&ttl, sizeof(ttl)))
}
if (connect(s, rp->ai_addr, rp->ai_addrlen) == 0) {
...
On server:
int minttl = 255 - maxhops;
getaddrinfo(NULL, port, &hints, &result);
for (rp = result; rp != NULL; rp = rp->ai_next) {
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (s < 0) continue;
if (rp->ai_family == AF_INET6)
setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
&minttl, sizeof(minttl));
setsockopt(s, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl));
if (bind(s, rp->ai_addr, rp->ai_addrlen) == 0)
break
...
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-23 06:24:53 +08:00
|
|
|
/* RFC5082: Generalized Ttl Security Mechanism */
|
|
|
|
#define IPV6_MINHOPCOUNT 73
|
|
|
|
|
2008-04-03 08:22:56 +08:00
|
|
|
/*
|
|
|
|
* Multicast Routing:
|
|
|
|
* see include/linux/mroute6.h.
|
|
|
|
*
|
|
|
|
* MRT6_INIT 200
|
|
|
|
* MRT6_DONE 201
|
|
|
|
* MRT6_ADD_MIF 202
|
|
|
|
* MRT6_DEL_MIF 203
|
|
|
|
* MRT6_ADD_MFC 204
|
|
|
|
* MRT6_DEL_MFC 205
|
|
|
|
* MRT6_VERSION 206
|
|
|
|
* MRT6_ASSERT 207
|
|
|
|
* MRT6_PIM 208
|
|
|
|
* (reserved) 209
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|