PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/Host/libeCos/src/net/tcpip/v2_0/include/netinet6/ipv6.h

https://github.com/LucidOne/Rovio
C Header | 156 lines | 76 code | 24 blank | 56 comment | 2 complexity | 82fba59f522a22de38cd645d4a323274 MD5 | raw file
Possible License(s): GPL-2.0
  1. //==========================================================================
  2. //
  3. // include/netinet6_ipv6.h
  4. //
  5. //
  6. //
  7. //==========================================================================
  8. //####BSDCOPYRIGHTBEGIN####
  9. //
  10. // -------------------------------------------
  11. //
  12. // Portions of this software may have been derived from OpenBSD or other sources,
  13. // and are covered by the appropriate copyright disclaimers included herein.
  14. //
  15. // -------------------------------------------
  16. //
  17. //####BSDCOPYRIGHTEND####
  18. //==========================================================================
  19. //#####DESCRIPTIONBEGIN####
  20. //
  21. // Author(s): gthomas
  22. // Contributors: gthomas
  23. // Date: 2000-01-10
  24. // Purpose:
  25. // Description:
  26. //
  27. //
  28. //####DESCRIPTIONEND####
  29. //
  30. //==========================================================================
  31. /*
  32. %%% copyright-nrl-95
  33. This software is Copyright 1995-1998 by Randall Atkinson, Ronald Lee,
  34. Daniel McDonald, Bao Phan, and Chris Winters. All Rights Reserved. All
  35. rights under this copyright have been assigned to the US Naval Research
  36. Laboratory (NRL). The NRL Copyright Notice and License Agreement Version
  37. 1.1 (January 17, 1995) applies to this software.
  38. You should have received a copy of the license with this software. If you
  39. didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
  40. */
  41. #ifndef _NETINET6_IPV6_H
  42. #define _NETINET6_IPV6_H 1
  43. #define IPV6VERSION 6
  44. /*
  45. * Header structures.
  46. */
  47. struct ipv6
  48. {
  49. uint32_t ipv6_versfl; /* Version and flow label word. */
  50. uint16_t ipv6_length; /* Datagram length (not including the length
  51. of this header). */
  52. uint8_t ipv6_nexthdr; /* Next header type. */
  53. uint8_t ipv6_hoplimit; /* Hop limit. */
  54. struct in6_addr ipv6_src; /* Source address. */
  55. struct in6_addr ipv6_dst; /* Destination address. */
  56. };
  57. #if __linux__
  58. #include <endian.h>
  59. #else /* __linux__ */
  60. #include <machine/endian.h>
  61. #endif /* __linux__ */
  62. struct ipv6hdr {
  63. #if BYTE_ORDER == LITTLE_ENDIAN
  64. uint8_t ipv6_priority:4; /* going away? */
  65. uint8_t ipv6_version:4;
  66. uint32_t ipv6_flowid:24;
  67. #elif BYTE_ORDER == BIG_ENDIAN
  68. uint32_t ipv6_flowid:24;
  69. uint8_t ipv6_priority:4; /* going away? */
  70. uint8_t ipv6_version:4;
  71. #else
  72. #error "Don't know what endian to use."
  73. #endif
  74. uint16_t ipv6_len;
  75. uint8_t ipv6_nextheader;
  76. uint8_t ipv6_hoplimit;
  77. struct in6_addr ipv6_src; /* source address */
  78. struct in6_addr ipv6_dst; /* destination address */
  79. };
  80. /*
  81. * Macros and defines for header fields, and values thereof.
  82. * Assume things are in host order for these three macros.
  83. */
  84. #define IPV6_VERSION(h) ((h)->ipv6_versfl >> 28)
  85. #define IPV6_PRIORITY(h) (((h)->ipv6_versfl & 0x0f000000) >> 24)
  86. #define IPV6_FLOWID(h) ((h)->ipv6_versfl & 0x00ffffff)
  87. #define MAXHOPLIMIT 64
  88. #define IPV6_MINMTU 576
  89. /*
  90. * Other IPv6 header definitions.
  91. */
  92. /* Fragmentation header & macros for it. NOTE: Host order assumption. */
  93. struct ipv6_fraghdr
  94. {
  95. uint8_t frag_nexthdr; /* Next header type. */
  96. uint8_t frag_reserved;
  97. uint16_t frag_bitsoffset; /* More bit and fragment offset. */
  98. uint32_t frag_id; /* Fragment identifier. */
  99. };
  100. #define FRAG_MOREMASK 0x1
  101. #define FRAG_OFFMASK 0xFFF8
  102. #define FRAG_MORE_BIT(fh) ((fh)->frag_bitsoffset & FRAG_MOREMASK)
  103. #define FRAG_OFFSET(fh) ((fh)->frag_bitsoffset & FRAG_OFFMASK)
  104. /* Source routing header. Host order assumption for macros. */
  105. struct ipv6_srcroute0
  106. {
  107. uint8_t i6sr_nexthdr; /* Next header type. */
  108. uint8_t i6sr_len; /* RH len in 8-byte addrs, !incl this structure */
  109. uint8_t i6sr_type; /* Routing type, should be 0 */
  110. uint8_t i6sr_left; /* Segments left */
  111. uint32_t i6sr_reserved; /* 8 bits of reserved padding. */
  112. };
  113. #define I6SR_BITMASK(i6sr) ((i6sr)->i6sr_reserved & 0xffffff)
  114. /* Options header. For "ignoreable" options. */
  115. struct ipv6_opthdr
  116. {
  117. uint8_t oh_nexthdr; /* Next header type. */
  118. uint8_t oh_extlen; /* Header extension length. */
  119. uint8_t oh_data[6]; /* Option data, may be reserved for
  120. alignment purposes. */
  121. };
  122. #define OPT_PAD1 0
  123. #define OPT_PADN 1
  124. #define OPT_JUMBO 194
  125. struct ipv6_option
  126. {
  127. uint8_t opt_type; /* Option type. */
  128. uint8_t opt_datalen; /* Option data length. */
  129. uint8_t opt_data[1]; /* Option data. */
  130. };
  131. #endif /* _NETINET6_IPV6_H */