ip6.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef _NETINET_IP6_H
  2. #define _NETINET_IP6_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #include <netinet/in.h>
  8. struct ip6_hdr {
  9. union {
  10. struct ip6_hdrctl {
  11. uint32_t ip6_un1_flow;
  12. uint16_t ip6_un1_plen;
  13. uint8_t ip6_un1_nxt;
  14. uint8_t ip6_un1_hlim;
  15. } ip6_un1;
  16. uint8_t ip6_un2_vfc;
  17. } ip6_ctlun;
  18. struct in6_addr ip6_src;
  19. struct in6_addr ip6_dst;
  20. };
  21. #define ip6_vfc ip6_ctlun.ip6_un2_vfc
  22. #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
  23. #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
  24. #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
  25. #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
  26. #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
  27. struct ip6_ext {
  28. uint8_t ip6e_nxt;
  29. uint8_t ip6e_len;
  30. };
  31. struct ip6_hbh {
  32. uint8_t ip6h_nxt;
  33. uint8_t ip6h_len;
  34. };
  35. struct ip6_dest {
  36. uint8_t ip6d_nxt;
  37. uint8_t ip6d_len;
  38. };
  39. struct ip6_rthdr {
  40. uint8_t ip6r_nxt;
  41. uint8_t ip6r_len;
  42. uint8_t ip6r_type;
  43. uint8_t ip6r_segleft;
  44. };
  45. struct ip6_rthdr0 {
  46. uint8_t ip6r0_nxt;
  47. uint8_t ip6r0_len;
  48. uint8_t ip6r0_type;
  49. uint8_t ip6r0_segleft;
  50. uint8_t ip6r0_reserved;
  51. uint8_t ip6r0_slmap[3];
  52. struct in6_addr ip6r0_addr[];
  53. };
  54. struct ip6_frag {
  55. uint8_t ip6f_nxt;
  56. uint8_t ip6f_reserved;
  57. uint16_t ip6f_offlg;
  58. uint32_t ip6f_ident;
  59. };
  60. #if __BYTE_ORDER == __BIG_ENDIAN
  61. #define IP6F_OFF_MASK 0xfff8
  62. #define IP6F_RESERVED_MASK 0x0006
  63. #define IP6F_MORE_FRAG 0x0001
  64. #else
  65. #define IP6F_OFF_MASK 0xf8ff
  66. #define IP6F_RESERVED_MASK 0x0600
  67. #define IP6F_MORE_FRAG 0x0100
  68. #endif
  69. struct ip6_opt {
  70. uint8_t ip6o_type;
  71. uint8_t ip6o_len;
  72. };
  73. #define IP6OPT_TYPE(o) ((o) & 0xc0)
  74. #define IP6OPT_TYPE_SKIP 0x00
  75. #define IP6OPT_TYPE_DISCARD 0x40
  76. #define IP6OPT_TYPE_FORCEICMP 0x80
  77. #define IP6OPT_TYPE_ICMP 0xc0
  78. #define IP6OPT_TYPE_MUTABLE 0x20
  79. #define IP6OPT_PAD1 0
  80. #define IP6OPT_PADN 1
  81. #define IP6OPT_JUMBO 0xc2
  82. #define IP6OPT_NSAP_ADDR 0xc3
  83. #define IP6OPT_TUNNEL_LIMIT 0x04
  84. #define IP6OPT_ROUTER_ALERT 0x05
  85. struct ip6_opt_jumbo {
  86. uint8_t ip6oj_type;
  87. uint8_t ip6oj_len;
  88. uint8_t ip6oj_jumbo_len[4];
  89. };
  90. #define IP6OPT_JUMBO_LEN 6
  91. struct ip6_opt_nsap {
  92. uint8_t ip6on_type;
  93. uint8_t ip6on_len;
  94. uint8_t ip6on_src_nsap_len;
  95. uint8_t ip6on_dst_nsap_len;
  96. };
  97. struct ip6_opt_tunnel {
  98. uint8_t ip6ot_type;
  99. uint8_t ip6ot_len;
  100. uint8_t ip6ot_encap_limit;
  101. };
  102. struct ip6_opt_router {
  103. uint8_t ip6or_type;
  104. uint8_t ip6or_len;
  105. uint8_t ip6or_value[2];
  106. };
  107. #if __BYTE_ORDER == __BIG_ENDIAN
  108. #define IP6_ALERT_MLD 0x0000
  109. #define IP6_ALERT_RSVP 0x0001
  110. #define IP6_ALERT_AN 0x0002
  111. #else
  112. #define IP6_ALERT_MLD 0x0000
  113. #define IP6_ALERT_RSVP 0x0100
  114. #define IP6_ALERT_AN 0x0200
  115. #endif
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif