1 struct icmp6_hdr { 2 uint8_t icmp6_type; /* type field */ 3 uint8_t icmp6_code; /* code field */ 4 uint16_t icmp6_cksum; /* checksum field */ 5 union { 6 uint32_t icmp6_un_data32[1]; /* type-specific field */ 7 uint16_t icmp6_un_data16[2]; /* type-specific field */ 8 uint8_t icmp6_un_data8[4]; /* type-specific field */ 9 } icmp6_dataun; 10 }; 11 12 #define icmp6_data32 icmp6_dataun.icmp6_un_data32 13 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 14 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 15 #define icmp6_pptr icmp6_data32[0] /* parameter prob */ 16 #define icmp6_mtu icmp6_data32[0] /* packet too big */ 17 #define icmp6_id icmp6_data16[0] /* echo request/reply */ 18 #define icmp6_seq icmp6_data16[1] /* echo request/reply */ 19 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ 20 21 #define ICMP6_DST_UNREACH 1 22 #define ICMP6_PACKET_TOO_BIG 2 23 #define ICMP6_TIME_EXCEEDED 3 24 #define ICMP6_PARAM_PROB 4 25 26 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 27 28 #define ICMP6_ECHO_REQUEST 128 29 #define ICMP6_ECHO_REPLY 129 30 #define ICMP6_MEMBERSHIP_QUERY 130 31 #define ICMP6_MEMBERSHIP_REPORT 131 32 #define ICMP6_MEMBERSHIP_REDUCTION 132 33 34 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ 35 #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ 36 /* administratively prohibited */ 37 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */ 38 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ 39 #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ 40 41 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ 42 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ 43 44 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ 45 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ 46 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ 47 48 #define ND_ROUTER_SOLICIT 133 49 #define ND_ROUTER_ADVERT 134 50 #define ND_NEIGHBOR_SOLICIT 135 51 #define ND_NEIGHBOR_ADVERT 136 52 #define ND_REDIRECT 137 53 54 struct nd_router_solicit { /* router solicitation */ 55 struct icmp6_hdr nd_rs_hdr; 56 /* could be followed by options */ 57 }; 58 59 #define nd_rs_type nd_rs_hdr.icmp6_type 60 #define nd_rs_code nd_rs_hdr.icmp6_code 61 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum 62 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 63 64 struct nd_router_advert { /* router advertisement */ 65 struct icmp6_hdr nd_ra_hdr; 66 uint32_t nd_ra_reachable; /* reachable time */ 67 uint32_t nd_ra_retransmit; /* retransmit timer */ 68 /* could be followed by options */ 69 }; 70 71 #define nd_ra_type nd_ra_hdr.icmp6_type 72 #define nd_ra_code nd_ra_hdr.icmp6_code 73 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum 74 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 75 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 76 #define ND_RA_FLAG_MANAGED 0x80 77 #define ND_RA_FLAG_OTHER 0x40 78 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 79 80 struct nd_neighbor_solicit { /* neighbor solicitation */ 81 struct icmp6_hdr nd_ns_hdr; 82 struct in6_addr nd_ns_target; /* target address */ 83 /* could be followed by options */ 84 }; 85 86 #define nd_ns_type nd_ns_hdr.icmp6_type 87 #define nd_ns_code nd_ns_hdr.icmp6_code 88 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum 89 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 90 91 struct nd_neighbor_advert { /* neighbor advertisement */ 92 struct icmp6_hdr nd_na_hdr; 93 struct in6_addr nd_na_target; /* target address */ 94 /* could be followed by options */ 95 }; 96 97 #define nd_na_type nd_na_hdr.icmp6_type 98 #define nd_na_code nd_na_hdr.icmp6_code 99 #define nd_na_cksum nd_na_hdr.icmp6_cksum 100 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 101 #define ND_NA_FLAG_ROUTER 0x80000000 102 #define ND_NA_FLAG_SOLICITED 0x40000000 103 #define ND_NA_FLAG_OVERRIDE 0x20000000 104 105 struct nd_redirect { /* redirect */ 106 struct icmp6_hdr nd_rd_hdr; 107 struct in6_addr nd_rd_target; /* target address */ 108 struct in6_addr nd_rd_dst; /* destination address */ 109 /* could be followed by options */ 110 }; 111 112 #define nd_rd_type nd_rd_hdr.icmp6_type 113 #define nd_rd_code nd_rd_hdr.icmp6_code 114 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum 115 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 116 117 struct nd_opt_hdr { /* Neighbor discovery option header */ 118 uint8_t nd_opt_type; 119 uint8_t nd_opt_len; /* in units of 8 octets */ 120 /* followed by option specific data */ 121 }; 122 123 #define ND_OPT_SOURCE_LINKADDR 1 124 #define ND_OPT_TARGET_LINKADDR 2 125 #define ND_OPT_PREFIX_INFORMATION 3 126 #define ND_OPT_REDIRECTED_HEADER 4 127 #define ND_OPT_MTU 5 128 129 struct nd_opt_prefix_info { /* prefix information */ 130 uint8_t nd_opt_pi_type; 131 uint8_t nd_opt_pi_len; 132 uint8_t nd_opt_pi_prefix_len; 133 uint8_t nd_opt_pi_flags_reserved; 134 uint32_t nd_opt_pi_valid_time; 135 uint32_t nd_opt_pi_preferred_time; 136 uint32_t nd_opt_pi_reserved2; 137 struct in6_addr nd_opt_pi_prefix; 138 }; 139 140 #define ND_OPT_PI_FLAG_ONLINK 0x80 141 #define ND_OPT_PI_FLAG_AUTO 0x40 142 143 struct nd_opt_rd_hdr { /* redirected header */ 144 uint8_t nd_opt_rh_type; 145 uint8_t nd_opt_rh_len; 146 uint16_t nd_opt_rh_reserved1; 147 uint32_t nd_opt_rh_reserved2; 148 /* followed by IP header and data */ 149 }; 150 151 struct nd_opt_mtu { /* MTU option */ 152 uint8_t nd_opt_mtu_type; 153 uint8_t nd_opt_mtu_len; 154 uint16_t nd_opt_mtu_reserved; 155 uint32_t nd_opt_mtu_mtu; 156 }; 157