ip6.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 02111-1307, USA. */
  15. #ifndef _NETINET_IP6_H
  16. #define _NETINET_IP6_H 1
  17. #include <inttypes.h>
  18. #include <netinet/in.h>
  19. struct ip6_hdr
  20. {
  21. union
  22. {
  23. struct ip6_hdrctl
  24. {
  25. uint32_t ip6_un1_flow; /* 24 bits of flow-ID */
  26. uint16_t ip6_un1_plen; /* payload length */
  27. uint8_t ip6_un1_nxt; /* next header */
  28. uint8_t ip6_un1_hlim; /* hop limit */
  29. } ip6_un1;
  30. uint8_t ip6_un2_vfc; /* 4 bits version, 4 bits priority */
  31. } ip6_ctlun;
  32. struct in6_addr ip6_src; /* source address */
  33. struct in6_addr ip6_dst; /* destination address */
  34. };
  35. #define ip6_vfc ip6_ctlun.ip6_un2_vfc
  36. #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
  37. #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
  38. #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
  39. #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
  40. #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
  41. /* Hop-by-Hop options header. */
  42. struct ip6_hbh
  43. {
  44. uint8_t ip6h_nxt; /* next hesder. */
  45. uint8_t ip6h_len; /* length in units of 8 octets. */
  46. /* followed by options */
  47. };
  48. /* Destination options header */
  49. struct ip6_dest
  50. {
  51. uint8_t ip6d_nxt; /* next header */
  52. uint8_t ip6d_len; /* length in units of 8 octets */
  53. /* followed by options */
  54. };
  55. /* Routing header */
  56. struct ip6_rthdr
  57. {
  58. uint8_t ip6r_nxt; /* next header */
  59. uint8_t ip6r_len; /* length in units of 8 octets */
  60. uint8_t ip6r_type; /* routing type */
  61. uint8_t ip6r_segleft; /* segments left */
  62. /* followed by routing type specific data */
  63. };
  64. /* Type 0 Routing header */
  65. struct ip6_rthdr0
  66. {
  67. uint8_t ip6r0_nxt; /* next header */
  68. uint8_t ip6r0_len; /* length in units of 8 octets */
  69. uint8_t ip6r0_type; /* always zero */
  70. uint8_t ip6r0_segleft; /* segments left */
  71. uint8_t ip6r0_reserved; /* reserved field */
  72. uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
  73. struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
  74. };
  75. /* Fragment header */
  76. struct ip6_frag
  77. {
  78. uint8_t ip6f_nxt; /* next header */
  79. uint8_t ip6f_reserved; /* reserved field */
  80. uint16_t ip6f_offlg; /* offset, reserved, and flag */
  81. uint32_t ip6f_ident; /* identification */
  82. };
  83. #if BYTE_ORDER == BIG_ENDIAN
  84. #define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
  85. #define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
  86. #define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
  87. #else /* BYTE_ORDER == LITTLE_ENDIAN */
  88. #define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
  89. #define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
  90. #define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
  91. #endif
  92. #endif /* netinet/ip6.h */