Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  *  Types and definitions for AF_INET6 
0004  *  Linux INET6 implementation 
0005  *
0006  *  Authors:
0007  *  Pedro Roque     <roque@di.fc.ul.pt> 
0008  *
0009  *  Sources:
0010  *  IPv6 Program Interfaces for BSD Systems
0011  *      <draft-ietf-ipngwg-bsd-api-05.txt>
0012  *
0013  *  Advanced Sockets API for IPv6
0014  *  <draft-stevens-advanced-api-00.txt>
0015  *
0016  *  This program is free software; you can redistribute it and/or
0017  *      modify it under the terms of the GNU General Public License
0018  *      as published by the Free Software Foundation; either version
0019  *      2 of the License, or (at your option) any later version.
0020  */
0021 
0022 #ifndef _UAPI_LINUX_IN6_H
0023 #define _UAPI_LINUX_IN6_H
0024 
0025 #include <linux/types.h>
0026 #include <linux/libc-compat.h>
0027 
0028 /*
0029  *  IPv6 address structure
0030  */
0031 
0032 #if __UAPI_DEF_IN6_ADDR
0033 struct in6_addr {
0034     union {
0035         __u8        u6_addr8[16];
0036 #if __UAPI_DEF_IN6_ADDR_ALT
0037         __be16      u6_addr16[8];
0038         __be32      u6_addr32[4];
0039 #endif
0040     } in6_u;
0041 #define s6_addr         in6_u.u6_addr8
0042 #if __UAPI_DEF_IN6_ADDR_ALT
0043 #define s6_addr16       in6_u.u6_addr16
0044 #define s6_addr32       in6_u.u6_addr32
0045 #endif
0046 };
0047 #endif /* __UAPI_DEF_IN6_ADDR */
0048 
0049 #if __UAPI_DEF_SOCKADDR_IN6
0050 struct sockaddr_in6 {
0051     unsigned short int  sin6_family;    /* AF_INET6 */
0052     __be16          sin6_port;      /* Transport layer port # */
0053     __be32          sin6_flowinfo;  /* IPv6 flow information */
0054     struct in6_addr     sin6_addr;      /* IPv6 address */
0055     __u32           sin6_scope_id;  /* scope id (new in RFC2553) */
0056 };
0057 #endif /* __UAPI_DEF_SOCKADDR_IN6 */
0058 
0059 #if __UAPI_DEF_IPV6_MREQ
0060 struct ipv6_mreq {
0061     /* IPv6 multicast address of group */
0062     struct in6_addr ipv6mr_multiaddr;
0063 
0064     /* local IPv6 address of interface */
0065     int     ipv6mr_ifindex;
0066 };
0067 #endif /* __UAPI_DEF_IVP6_MREQ */
0068 
0069 #define ipv6mr_acaddr   ipv6mr_multiaddr
0070 
0071 struct in6_flowlabel_req {
0072     struct in6_addr flr_dst;
0073     __be32  flr_label;
0074     __u8    flr_action;
0075     __u8    flr_share;
0076     __u16   flr_flags;
0077     __u16   flr_expires;
0078     __u16   flr_linger;
0079     __u32   __flr_pad;
0080     /* Options in format of IPV6_PKTOPTIONS */
0081 };
0082 
0083 #define IPV6_FL_A_GET   0
0084 #define IPV6_FL_A_PUT   1
0085 #define IPV6_FL_A_RENEW 2
0086 
0087 #define IPV6_FL_F_CREATE    1
0088 #define IPV6_FL_F_EXCL      2
0089 #define IPV6_FL_F_REFLECT   4
0090 #define IPV6_FL_F_REMOTE    8
0091 
0092 #define IPV6_FL_S_NONE      0
0093 #define IPV6_FL_S_EXCL      1
0094 #define IPV6_FL_S_PROCESS   2
0095 #define IPV6_FL_S_USER      3
0096 #define IPV6_FL_S_ANY       255
0097 
0098 
0099 /*
0100  *  Bitmask constant declarations to help applications select out the 
0101  *  flow label and priority fields.
0102  *
0103  *  Note that this are in host byte order while the flowinfo field of
0104  *  sockaddr_in6 is in network byte order.
0105  */
0106 
0107 #define IPV6_FLOWINFO_FLOWLABEL     0x000fffff
0108 #define IPV6_FLOWINFO_PRIORITY      0x0ff00000
0109 
0110 /* These definitions are obsolete */
0111 #define IPV6_PRIORITY_UNCHARACTERIZED   0x0000
0112 #define IPV6_PRIORITY_FILLER        0x0100
0113 #define IPV6_PRIORITY_UNATTENDED    0x0200
0114 #define IPV6_PRIORITY_RESERVED1     0x0300
0115 #define IPV6_PRIORITY_BULK      0x0400
0116 #define IPV6_PRIORITY_RESERVED2     0x0500
0117 #define IPV6_PRIORITY_INTERACTIVE   0x0600
0118 #define IPV6_PRIORITY_CONTROL       0x0700
0119 #define IPV6_PRIORITY_8         0x0800
0120 #define IPV6_PRIORITY_9         0x0900
0121 #define IPV6_PRIORITY_10        0x0a00
0122 #define IPV6_PRIORITY_11        0x0b00
0123 #define IPV6_PRIORITY_12        0x0c00
0124 #define IPV6_PRIORITY_13        0x0d00
0125 #define IPV6_PRIORITY_14        0x0e00
0126 #define IPV6_PRIORITY_15        0x0f00
0127 
0128 /*
0129  *  IPV6 extension headers
0130  */
0131 #if __UAPI_DEF_IPPROTO_V6
0132 #define IPPROTO_HOPOPTS     0   /* IPv6 hop-by-hop options  */
0133 #define IPPROTO_ROUTING     43  /* IPv6 routing header      */
0134 #define IPPROTO_FRAGMENT    44  /* IPv6 fragmentation header    */
0135 #define IPPROTO_ICMPV6      58  /* ICMPv6           */
0136 #define IPPROTO_NONE        59  /* IPv6 no next header      */
0137 #define IPPROTO_DSTOPTS     60  /* IPv6 destination options */
0138 #define IPPROTO_MH      135 /* IPv6 mobility header     */
0139 #endif /* __UAPI_DEF_IPPROTO_V6 */
0140 
0141 /*
0142  *  IPv6 TLV options.
0143  */
0144 #define IPV6_TLV_PAD1       0
0145 #define IPV6_TLV_PADN       1
0146 #define IPV6_TLV_ROUTERALERT    5
0147 #define IPV6_TLV_CALIPSO    7   /* RFC 5570 */
0148 #define IPV6_TLV_IOAM       49  /* TEMPORARY IANA allocation for IOAM */
0149 #define IPV6_TLV_JUMBO      194
0150 #define IPV6_TLV_HAO        201 /* home address option */
0151 
0152 /*
0153  *  IPV6 socket options
0154  */
0155 #if __UAPI_DEF_IPV6_OPTIONS
0156 #define IPV6_ADDRFORM       1
0157 #define IPV6_2292PKTINFO    2
0158 #define IPV6_2292HOPOPTS    3
0159 #define IPV6_2292DSTOPTS    4
0160 #define IPV6_2292RTHDR      5
0161 #define IPV6_2292PKTOPTIONS 6
0162 #define IPV6_CHECKSUM       7
0163 #define IPV6_2292HOPLIMIT   8
0164 #define IPV6_NEXTHOP        9
0165 #define IPV6_AUTHHDR        10  /* obsolete */
0166 #define IPV6_FLOWINFO       11
0167 
0168 #define IPV6_UNICAST_HOPS   16
0169 #define IPV6_MULTICAST_IF   17
0170 #define IPV6_MULTICAST_HOPS 18
0171 #define IPV6_MULTICAST_LOOP 19
0172 #define IPV6_ADD_MEMBERSHIP 20
0173 #define IPV6_DROP_MEMBERSHIP    21
0174 #define IPV6_ROUTER_ALERT   22
0175 #define IPV6_MTU_DISCOVER   23
0176 #define IPV6_MTU        24
0177 #define IPV6_RECVERR        25
0178 #define IPV6_V6ONLY     26
0179 #define IPV6_JOIN_ANYCAST   27
0180 #define IPV6_LEAVE_ANYCAST  28
0181 #define IPV6_MULTICAST_ALL  29
0182 #define IPV6_ROUTER_ALERT_ISOLATE   30
0183 #define IPV6_RECVERR_RFC4884    31
0184 
0185 /* IPV6_MTU_DISCOVER values */
0186 #define IPV6_PMTUDISC_DONT      0
0187 #define IPV6_PMTUDISC_WANT      1
0188 #define IPV6_PMTUDISC_DO        2
0189 #define IPV6_PMTUDISC_PROBE     3
0190 /* same as IPV6_PMTUDISC_PROBE, provided for symetry with IPv4
0191  * also see comments on IP_PMTUDISC_INTERFACE
0192  */
0193 #define IPV6_PMTUDISC_INTERFACE     4
0194 /* weaker version of IPV6_PMTUDISC_INTERFACE, which allows packets to
0195  * get fragmented if they exceed the interface mtu
0196  */
0197 #define IPV6_PMTUDISC_OMIT      5
0198 
0199 /* Flowlabel */
0200 #define IPV6_FLOWLABEL_MGR  32
0201 #define IPV6_FLOWINFO_SEND  33
0202 
0203 #define IPV6_IPSEC_POLICY   34
0204 #define IPV6_XFRM_POLICY    35
0205 #define IPV6_HDRINCL        36
0206 #endif
0207 
0208 /*
0209  * Multicast:
0210  * Following socket options are shared between IPv4 and IPv6.
0211  *
0212  * MCAST_JOIN_GROUP     42
0213  * MCAST_BLOCK_SOURCE       43
0214  * MCAST_UNBLOCK_SOURCE     44
0215  * MCAST_LEAVE_GROUP        45
0216  * MCAST_JOIN_SOURCE_GROUP  46
0217  * MCAST_LEAVE_SOURCE_GROUP 47
0218  * MCAST_MSFILTER       48
0219  */
0220 
0221 /*
0222  * Advanced API (RFC3542) (1)
0223  *
0224  * Note: IPV6_RECVRTHDRDSTOPTS does not exist. see net/ipv6/datagram.c.
0225  */
0226 
0227 #define IPV6_RECVPKTINFO    49
0228 #define IPV6_PKTINFO        50
0229 #define IPV6_RECVHOPLIMIT   51
0230 #define IPV6_HOPLIMIT       52
0231 #define IPV6_RECVHOPOPTS    53
0232 #define IPV6_HOPOPTS        54
0233 #define IPV6_RTHDRDSTOPTS   55
0234 #define IPV6_RECVRTHDR      56
0235 #define IPV6_RTHDR      57
0236 #define IPV6_RECVDSTOPTS    58
0237 #define IPV6_DSTOPTS        59
0238 #define IPV6_RECVPATHMTU    60
0239 #define IPV6_PATHMTU        61
0240 #define IPV6_DONTFRAG       62
0241 #if 0   /* not yet */
0242 #define IPV6_USE_MIN_MTU    63
0243 #endif
0244 
0245 /*
0246  * Netfilter (1)
0247  *
0248  * Following socket options are used in ip6_tables;
0249  * see include/linux/netfilter_ipv6/ip6_tables.h.
0250  *
0251  * IP6T_SO_SET_REPLACE / IP6T_SO_GET_INFO       64
0252  * IP6T_SO_SET_ADD_COUNTERS / IP6T_SO_GET_ENTRIES   65
0253  */
0254 
0255 /*
0256  * Advanced API (RFC3542) (2)
0257  */
0258 #define IPV6_RECVTCLASS     66
0259 #define IPV6_TCLASS     67
0260 
0261 /*
0262  * Netfilter (2)
0263  *
0264  * Following socket options are used in ip6_tables;
0265  * see include/linux/netfilter_ipv6/ip6_tables.h.
0266  *
0267  * IP6T_SO_GET_REVISION_MATCH   68
0268  * IP6T_SO_GET_REVISION_TARGET  69
0269  * IP6T_SO_ORIGINAL_DST     80
0270  */
0271 
0272 #define IPV6_AUTOFLOWLABEL  70
0273 /* RFC5014: Source address selection */
0274 #define IPV6_ADDR_PREFERENCES   72
0275 
0276 #define IPV6_PREFER_SRC_TMP     0x0001
0277 #define IPV6_PREFER_SRC_PUBLIC      0x0002
0278 #define IPV6_PREFER_SRC_PUBTMP_DEFAULT  0x0100
0279 #define IPV6_PREFER_SRC_COA     0x0004
0280 #define IPV6_PREFER_SRC_HOME        0x0400
0281 #define IPV6_PREFER_SRC_CGA     0x0008
0282 #define IPV6_PREFER_SRC_NONCGA      0x0800
0283 
0284 /* RFC5082: Generalized Ttl Security Mechanism */
0285 #define IPV6_MINHOPCOUNT        73
0286 
0287 #define IPV6_ORIGDSTADDR        74
0288 #define IPV6_RECVORIGDSTADDR    IPV6_ORIGDSTADDR
0289 #define IPV6_TRANSPARENT        75
0290 #define IPV6_UNICAST_IF         76
0291 #define IPV6_RECVFRAGSIZE   77
0292 #define IPV6_FREEBIND       78
0293 
0294 /*
0295  * Multicast Routing:
0296  * see include/uapi/linux/mroute6.h.
0297  *
0298  * MRT6_BASE            200
0299  * ...
0300  * MRT6_MAX
0301  */
0302 #endif /* _UAPI_LINUX_IN6_H */