PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/include/linux/ipv6.h

https://bitbucket.org/evzijst/gittest
C Header | 316 lines | 216 code | 52 blank | 48 comment | 5 complexity | 1a4f2a16bce2d91cc40ed3ba4a5496f5 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0
  1. #ifndef _IPV6_H
  2. #define _IPV6_H
  3. #include <linux/config.h>
  4. #include <linux/in6.h>
  5. #include <asm/byteorder.h>
  6. /* The latest drafts declared increase in minimal mtu up to 1280. */
  7. #define IPV6_MIN_MTU 1280
  8. /*
  9. * Advanced API
  10. * source interface/address selection, source routing, etc...
  11. * *under construction*
  12. */
  13. struct in6_pktinfo {
  14. struct in6_addr ipi6_addr;
  15. int ipi6_ifindex;
  16. };
  17. struct in6_ifreq {
  18. struct in6_addr ifr6_addr;
  19. __u32 ifr6_prefixlen;
  20. int ifr6_ifindex;
  21. };
  22. #define IPV6_SRCRT_STRICT 0x01 /* this hop must be a neighbor */
  23. #define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */
  24. /*
  25. * routing header
  26. */
  27. struct ipv6_rt_hdr {
  28. __u8 nexthdr;
  29. __u8 hdrlen;
  30. __u8 type;
  31. __u8 segments_left;
  32. /*
  33. * type specific data
  34. * variable length field
  35. */
  36. };
  37. struct ipv6_opt_hdr {
  38. __u8 nexthdr;
  39. __u8 hdrlen;
  40. /*
  41. * TLV encoded option data follows.
  42. */
  43. };
  44. #define ipv6_destopt_hdr ipv6_opt_hdr
  45. #define ipv6_hopopt_hdr ipv6_opt_hdr
  46. #ifdef __KERNEL__
  47. #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
  48. #endif
  49. /*
  50. * routing header type 0 (used in cmsghdr struct)
  51. */
  52. struct rt0_hdr {
  53. struct ipv6_rt_hdr rt_hdr;
  54. __u32 bitmap; /* strict/loose bit map */
  55. struct in6_addr addr[0];
  56. #define rt0_type rt_hdr.type
  57. };
  58. struct ipv6_auth_hdr {
  59. __u8 nexthdr;
  60. __u8 hdrlen; /* This one is measured in 32 bit units! */
  61. __u16 reserved;
  62. __u32 spi;
  63. __u32 seq_no; /* Sequence number */
  64. __u8 auth_data[0]; /* Length variable but >=4. Mind the 64 bit alignment! */
  65. };
  66. struct ipv6_esp_hdr {
  67. __u32 spi;
  68. __u32 seq_no; /* Sequence number */
  69. __u8 enc_data[0]; /* Length variable but >=8. Mind the 64 bit alignment! */
  70. };
  71. struct ipv6_comp_hdr {
  72. __u8 nexthdr;
  73. __u8 flags;
  74. __u16 cpi;
  75. };
  76. /*
  77. * IPv6 fixed header
  78. *
  79. * BEWARE, it is incorrect. The first 4 bits of flow_lbl
  80. * are glued to priority now, forming "class".
  81. */
  82. struct ipv6hdr {
  83. #if defined(__LITTLE_ENDIAN_BITFIELD)
  84. __u8 priority:4,
  85. version:4;
  86. #elif defined(__BIG_ENDIAN_BITFIELD)
  87. __u8 version:4,
  88. priority:4;
  89. #else
  90. #error "Please fix <asm/byteorder.h>"
  91. #endif
  92. __u8 flow_lbl[3];
  93. __u16 payload_len;
  94. __u8 nexthdr;
  95. __u8 hop_limit;
  96. struct in6_addr saddr;
  97. struct in6_addr daddr;
  98. };
  99. /*
  100. * This structure contains configuration options per IPv6 link.
  101. */
  102. struct ipv6_devconf {
  103. __s32 forwarding;
  104. __s32 hop_limit;
  105. __s32 mtu6;
  106. __s32 accept_ra;
  107. __s32 accept_redirects;
  108. __s32 autoconf;
  109. __s32 dad_transmits;
  110. __s32 rtr_solicits;
  111. __s32 rtr_solicit_interval;
  112. __s32 rtr_solicit_delay;
  113. __s32 force_mld_version;
  114. #ifdef CONFIG_IPV6_PRIVACY
  115. __s32 use_tempaddr;
  116. __s32 temp_valid_lft;
  117. __s32 temp_prefered_lft;
  118. __s32 regen_max_retry;
  119. __s32 max_desync_factor;
  120. #endif
  121. __s32 max_addresses;
  122. void *sysctl;
  123. };
  124. /* index values for the variables in ipv6_devconf */
  125. enum {
  126. DEVCONF_FORWARDING = 0,
  127. DEVCONF_HOPLIMIT,
  128. DEVCONF_MTU6,
  129. DEVCONF_ACCEPT_RA,
  130. DEVCONF_ACCEPT_REDIRECTS,
  131. DEVCONF_AUTOCONF,
  132. DEVCONF_DAD_TRANSMITS,
  133. DEVCONF_RTR_SOLICITS,
  134. DEVCONF_RTR_SOLICIT_INTERVAL,
  135. DEVCONF_RTR_SOLICIT_DELAY,
  136. DEVCONF_USE_TEMPADDR,
  137. DEVCONF_TEMP_VALID_LFT,
  138. DEVCONF_TEMP_PREFERED_LFT,
  139. DEVCONF_REGEN_MAX_RETRY,
  140. DEVCONF_MAX_DESYNC_FACTOR,
  141. DEVCONF_MAX_ADDRESSES,
  142. DEVCONF_FORCE_MLD_VERSION,
  143. DEVCONF_MAX
  144. };
  145. #ifdef __KERNEL__
  146. #include <linux/in6.h> /* struct sockaddr_in6 */
  147. #include <linux/icmpv6.h>
  148. #include <net/if_inet6.h> /* struct ipv6_mc_socklist */
  149. #include <linux/tcp.h>
  150. #include <linux/udp.h>
  151. /*
  152. This structure contains results of exthdrs parsing
  153. as offsets from skb->nh.
  154. */
  155. struct inet6_skb_parm {
  156. int iif;
  157. __u16 ra;
  158. __u16 hop;
  159. __u16 dst0;
  160. __u16 srcrt;
  161. __u16 dst1;
  162. };
  163. #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
  164. /**
  165. * struct ipv6_pinfo - ipv6 private area
  166. *
  167. * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc)
  168. * this _must_ be the last member, so that inet6_sk_generic
  169. * is able to calculate its offset from the base struct sock
  170. * by using the struct proto->slab_obj_size member. -acme
  171. */
  172. struct ipv6_pinfo {
  173. struct in6_addr saddr;
  174. struct in6_addr rcv_saddr;
  175. struct in6_addr daddr;
  176. struct in6_addr *daddr_cache;
  177. __u32 flow_label;
  178. __u32 frag_size;
  179. __s16 hop_limit;
  180. __s16 mcast_hops;
  181. int mcast_oif;
  182. /* pktoption flags */
  183. union {
  184. struct {
  185. __u8 srcrt:2,
  186. rxinfo:1,
  187. rxhlim:1,
  188. hopopts:1,
  189. dstopts:1,
  190. rxflow:1;
  191. } bits;
  192. __u8 all;
  193. } rxopt;
  194. /* sockopt flags */
  195. __u8 mc_loop:1,
  196. recverr:1,
  197. sndflow:1,
  198. pmtudisc:2,
  199. ipv6only:1;
  200. __u32 dst_cookie;
  201. struct ipv6_mc_socklist *ipv6_mc_list;
  202. struct ipv6_ac_socklist *ipv6_ac_list;
  203. struct ipv6_fl_socklist *ipv6_fl_list;
  204. struct ipv6_txoptions *opt;
  205. struct sk_buff *pktoptions;
  206. struct {
  207. struct ipv6_txoptions *opt;
  208. struct rt6_info *rt;
  209. int hop_limit;
  210. } cork;
  211. };
  212. /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
  213. struct raw6_sock {
  214. /* inet_sock has to be the first member of raw6_sock */
  215. struct inet_sock inet;
  216. __u32 checksum; /* perform checksum */
  217. __u32 offset; /* checksum offset */
  218. struct icmp6_filter filter;
  219. /* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
  220. struct ipv6_pinfo inet6;
  221. };
  222. struct udp6_sock {
  223. struct udp_sock udp;
  224. /* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
  225. struct ipv6_pinfo inet6;
  226. };
  227. struct tcp6_sock {
  228. struct tcp_sock tcp;
  229. /* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
  230. struct ipv6_pinfo inet6;
  231. };
  232. #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
  233. static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
  234. {
  235. return inet_sk(__sk)->pinet6;
  236. }
  237. static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  238. {
  239. return (struct raw6_sock *)sk;
  240. }
  241. static inline void inet_sk_copy_descendant(struct sock *sk_to,
  242. const struct sock *sk_from)
  243. {
  244. int ancestor_size = sizeof(struct inet_sock);
  245. if (sk_from->sk_family == PF_INET6)
  246. ancestor_size += sizeof(struct ipv6_pinfo);
  247. __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
  248. }
  249. #define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only)
  250. #define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
  251. #else
  252. #define __ipv6_only_sock(sk) 0
  253. #define ipv6_only_sock(sk) 0
  254. static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
  255. {
  256. return NULL;
  257. }
  258. static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  259. {
  260. return NULL;
  261. }
  262. #endif
  263. #endif
  264. #endif