| 1 |
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 |
#ifndef _IPV6_H |
| 3 |
#define _IPV6_H |
| 4 |
|
| 5 |
#include <linux/libc-compat.h> |
| 6 |
#include <linux/types.h> |
| 7 |
#include <linux/stddef.h> |
| 8 |
#include <linux/in6.h> |
| 9 |
#include <asm/byteorder.h> |
| 10 |
|
| 11 |
/* The latest drafts declared increase in minimal mtu up to 1280. */ |
| 12 |
|
| 13 |
#define IPV6_MIN_MTU 1280 |
| 14 |
|
| 15 |
/* |
| 16 |
* Advanced API |
| 17 |
* source interface/address selection, source routing, etc... |
| 18 |
* *under construction* |
| 19 |
*/ |
| 20 |
|
| 21 |
#if __UAPI_DEF_IN6_PKTINFO |
| 22 |
struct in6_pktinfo { |
| 23 |
struct in6_addr ipi6_addr; |
| 24 |
int ipi6_ifindex; |
| 25 |
}; |
| 26 |
#endif |
| 27 |
|
| 28 |
#if __UAPI_DEF_IP6_MTUINFO |
| 29 |
struct ip6_mtuinfo { |
| 30 |
struct sockaddr_in6 ip6m_addr; |
| 31 |
__u32 ip6m_mtu; |
| 32 |
}; |
| 33 |
#endif |
| 34 |
|
| 35 |
struct in6_ifreq { |
| 36 |
struct in6_addr ifr6_addr; |
| 37 |
__u32 ifr6_prefixlen; |
| 38 |
int ifr6_ifindex; |
| 39 |
}; |
| 40 |
|
| 41 |
#define IPV6_SRCRT_STRICT 0x01 /* Deprecated; will be removed */ |
| 42 |
#define IPV6_SRCRT_TYPE_0 0 /* Deprecated; will be removed */ |
| 43 |
#define IPV6_SRCRT_TYPE_2 2 /* IPv6 type 2 Routing Header */ |
| 44 |
#define IPV6_SRCRT_TYPE_3 3 /* RPL Segment Routing with IPv6 */ |
| 45 |
#define IPV6_SRCRT_TYPE_4 4 /* Segment Routing with IPv6 */ |
| 46 |
|
| 47 |
/* |
| 48 |
* routing header |
| 49 |
*/ |
| 50 |
struct ipv6_rt_hdr { |
| 51 |
__u8 nexthdr; |
| 52 |
__u8 hdrlen; |
| 53 |
__u8 type; |
| 54 |
__u8 segments_left; |
| 55 |
|
| 56 |
/* |
| 57 |
* type specific data |
| 58 |
* variable length field |
| 59 |
*/ |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
struct ipv6_opt_hdr { |
| 64 |
__u8 nexthdr; |
| 65 |
__u8 hdrlen; |
| 66 |
/* |
| 67 |
* TLV encoded option data follows. |
| 68 |
*/ |
| 69 |
} __attribute__((packed)); /* required for some archs */ |
| 70 |
|
| 71 |
#define ipv6_destopt_hdr ipv6_opt_hdr |
| 72 |
#define ipv6_hopopt_hdr ipv6_opt_hdr |
| 73 |
|
| 74 |
/* Router Alert option values (RFC2711) */ |
| 75 |
#define IPV6_OPT_ROUTERALERT_MLD 0x0000 /* MLD(RFC2710) */ |
| 76 |
|
| 77 |
/* |
| 78 |
* routing header type 0 (used in cmsghdr struct) |
| 79 |
*/ |
| 80 |
|
| 81 |
struct rt0_hdr { |
| 82 |
struct ipv6_rt_hdr rt_hdr; |
| 83 |
__u32 reserved; |
| 84 |
struct in6_addr addr[]; |
| 85 |
|
| 86 |
#define rt0_type rt_hdr.type |
| 87 |
}; |
| 88 |
|
| 89 |
/* |
| 90 |
* routing header type 2 |
| 91 |
*/ |
| 92 |
|
| 93 |
struct rt2_hdr { |
| 94 |
struct ipv6_rt_hdr rt_hdr; |
| 95 |
__u32 reserved; |
| 96 |
struct in6_addr addr; |
| 97 |
|
| 98 |
#define rt2_type rt_hdr.type |
| 99 |
}; |
| 100 |
|
| 101 |
/* |
| 102 |
* home address option in destination options header |
| 103 |
*/ |
| 104 |
|
| 105 |
struct ipv6_destopt_hao { |
| 106 |
__u8 type; |
| 107 |
__u8 length; |
| 108 |
struct in6_addr addr; |
| 109 |
} __attribute__((packed)); |
| 110 |
|
| 111 |
/* |
| 112 |
* IPv6 fixed header |
| 113 |
* |
| 114 |
* BEWARE, it is incorrect. The first 4 bits of flow_lbl |
| 115 |
* are glued to priority now, forming "class". |
| 116 |
*/ |
| 117 |
|
| 118 |
struct ipv6hdr { |
| 119 |
#if defined(__LITTLE_ENDIAN_BITFIELD) |
| 120 |
__u8 priority:4, |
| 121 |
version:4; |
| 122 |
#elif defined(__BIG_ENDIAN_BITFIELD) |
| 123 |
__u8 version:4, |
| 124 |
priority:4; |
| 125 |
#else |
| 126 |
#error "Please fix <asm/byteorder.h>" |
| 127 |
#endif |
| 128 |
__u8 flow_lbl[3]; |
| 129 |
|
| 130 |
__be16 payload_len; |
| 131 |
__u8 nexthdr; |
| 132 |
__u8 hop_limit; |
| 133 |
|
| 134 |
__struct_group(/* no tag */, addrs, /* no attrs */, |
| 135 |
struct in6_addr saddr; |
| 136 |
struct in6_addr daddr; |
| 137 |
); |
| 138 |
}; |
| 139 |
|
| 140 |
|
| 141 |
/* index values for the variables in ipv6_devconf */ |
| 142 |
enum { |
| 143 |
DEVCONF_FORWARDING = 0, |
| 144 |
DEVCONF_HOPLIMIT, |
| 145 |
DEVCONF_MTU6, |
| 146 |
DEVCONF_ACCEPT_RA, |
| 147 |
DEVCONF_ACCEPT_REDIRECTS, |
| 148 |
DEVCONF_AUTOCONF, |
| 149 |
DEVCONF_DAD_TRANSMITS, |
| 150 |
DEVCONF_RTR_SOLICITS, |
| 151 |
DEVCONF_RTR_SOLICIT_INTERVAL, |
| 152 |
DEVCONF_RTR_SOLICIT_DELAY, |
| 153 |
DEVCONF_USE_TEMPADDR, |
| 154 |
DEVCONF_TEMP_VALID_LFT, |
| 155 |
DEVCONF_TEMP_PREFERED_LFT, |
| 156 |
DEVCONF_REGEN_MAX_RETRY, |
| 157 |
DEVCONF_MAX_DESYNC_FACTOR, |
| 158 |
DEVCONF_MAX_ADDRESSES, |
| 159 |
DEVCONF_FORCE_MLD_VERSION, |
| 160 |
DEVCONF_ACCEPT_RA_DEFRTR, |
| 161 |
DEVCONF_ACCEPT_RA_PINFO, |
| 162 |
DEVCONF_ACCEPT_RA_RTR_PREF, |
| 163 |
DEVCONF_RTR_PROBE_INTERVAL, |
| 164 |
DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN, |
| 165 |
DEVCONF_PROXY_NDP, |
| 166 |
DEVCONF_OPTIMISTIC_DAD, |
| 167 |
DEVCONF_ACCEPT_SOURCE_ROUTE, |
| 168 |
DEVCONF_MC_FORWARDING, |
| 169 |
DEVCONF_DISABLE_IPV6, |
| 170 |
DEVCONF_ACCEPT_DAD, |
| 171 |
DEVCONF_FORCE_TLLAO, |
| 172 |
DEVCONF_NDISC_NOTIFY, |
| 173 |
DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL, |
| 174 |
DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL, |
| 175 |
DEVCONF_SUPPRESS_FRAG_NDISC, |
| 176 |
DEVCONF_ACCEPT_RA_FROM_LOCAL, |
| 177 |
DEVCONF_USE_OPTIMISTIC, |
| 178 |
DEVCONF_ACCEPT_RA_MTU, |
| 179 |
DEVCONF_STABLE_SECRET, |
| 180 |
DEVCONF_USE_OIF_ADDRS_ONLY, |
| 181 |
DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT, |
| 182 |
DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN, |
| 183 |
DEVCONF_DROP_UNICAST_IN_L2_MULTICAST, |
| 184 |
DEVCONF_DROP_UNSOLICITED_NA, |
| 185 |
DEVCONF_KEEP_ADDR_ON_DOWN, |
| 186 |
DEVCONF_RTR_SOLICIT_MAX_INTERVAL, |
| 187 |
DEVCONF_SEG6_ENABLED, |
| 188 |
DEVCONF_SEG6_REQUIRE_HMAC, |
| 189 |
DEVCONF_ENHANCED_DAD, |
| 190 |
DEVCONF_ADDR_GEN_MODE, |
| 191 |
DEVCONF_DISABLE_POLICY, |
| 192 |
DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, |
| 193 |
DEVCONF_NDISC_TCLASS, |
| 194 |
DEVCONF_RPL_SEG_ENABLED, |
| 195 |
DEVCONF_RA_DEFRTR_METRIC, |
| 196 |
DEVCONF_IOAM6_ENABLED, |
| 197 |
DEVCONF_IOAM6_ID, |
| 198 |
DEVCONF_IOAM6_ID_WIDE, |
| 199 |
DEVCONF_NDISC_EVICT_NOCARRIER, |
| 200 |
DEVCONF_ACCEPT_UNTRACKED_NA, |
| 201 |
DEVCONF_MAX |
| 202 |
}; |
| 203 |
|
| 204 |
|
| 205 |
#endif /* _IPV6_H */ |