1 /* 2 * Fundamental constants relating to Neighbor Discovery Protocol 3 * 4 * Copyright (C) 1999-2019, Broadcom. 5 * 6 * Unless you and Broadcom execute a separate written software license 7 * agreement governing use of this software, this software is licensed to you 8 * under the terms of the GNU General Public License version 2 (the "GPL"), 9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 * following added to such license: 11 * 12 * As a special exception, the copyright holders of this software give you 13 * permission to link this software with independent modules, and to copy and 14 * distribute the resulting executable under terms of your choice, provided that 15 * you also meet, for each linked independent module, the terms and conditions 16 * of the license of that module. An independent module is a module which is 17 * not derived from this software. The special exception does not apply to any 18 * modifications of the software. 19 * 20 * Notwithstanding the above, under no circumstances may you combine this 21 * software in any way with any other Broadcom software provided under a license 22 * other than the GPL, without Broadcom's express prior written consent. 23 * 24 * 25 * <<Broadcom-WL-IPTag/Open:>> 26 * 27 * $Id: bcmipv6.h 700076 2017-05-17 14:42:22Z $ 28 */ 29 30 #ifndef _bcmipv6_h_ 31 #define _bcmipv6_h_ 32 33 #ifndef _TYPEDEFS_H_ 34 #include <typedefs.h> 35 #endif // endif 36 37 /* This marks the start of a packed structure section. */ 38 #include <packed_section_start.h> 39 40 /* Extension headers */ 41 #define IPV6_EXT_HOP 0 42 #define IPV6_EXT_ROUTE 43 43 #define IPV6_EXT_FRAG 44 44 #define IPV6_EXT_DEST 60 45 #define IPV6_EXT_ESEC 50 46 #define IPV6_EXT_AUTH 51 47 48 /* Minimum size (extension header "word" length) */ 49 #define IPV6_EXT_WORD 8 50 51 /* Offsets for most extension headers */ 52 #define IPV6_EXT_NEXTHDR 0 53 #define IPV6_EXT_HDRLEN 1 54 55 /* Constants specific to fragmentation header */ 56 #define IPV6_FRAG_MORE_MASK 0x0001 57 #define IPV6_FRAG_MORE_SHIFT 0 58 #define IPV6_FRAG_OFFS_MASK 0xfff8 59 #define IPV6_FRAG_OFFS_SHIFT 3 60 61 /* For icmpv6 */ 62 #define ICMPV6_HEADER_TYPE 0x3A 63 #define ICMPV6_PKT_TYPE_RA 134 64 #define ICMPV6_PKT_TYPE_NS 135 65 #define ICMPV6_PKT_TYPE_NA 136 66 67 #define ICMPV6_ND_OPT_TYPE_TARGET_MAC 2 68 #define ICMPV6_ND_OPT_TYPE_SRC_MAC 1 69 70 #define ICMPV6_ND_OPT_LEN_LINKADDR 1 71 72 #define ICMPV6_ND_OPT_LEN_LINKADDR 1 73 74 #define IPV6_VERSION 6 75 #define IPV6_HOP_LIMIT 255 76 77 #define IPV6_ADDR_NULL(a) \ 78 ((a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7] | a[8] | a[9] | \ 79 a[10] | a[11] | a[12] | a[13] | a[14] | a[15]) == 0) 80 81 #define IPV6_ADDR_LOCAL(a) (((a[0] == 0xfe) && (a[1] & 0x80)) ? TRUE : FALSE) 82 83 /* IPV6 address */ 84 BWL_PRE_PACKED_STRUCT struct ipv6_addr { 85 uint8 addr[16]; 86 } BWL_POST_PACKED_STRUCT; 87 88 /* ICMPV6 Header */ 89 BWL_PRE_PACKED_STRUCT struct icmp6_hdr { 90 uint8 icmp6_type; 91 uint8 icmp6_code; 92 uint16 icmp6_cksum; 93 BWL_PRE_PACKED_STRUCT union { 94 uint32 reserved; 95 BWL_PRE_PACKED_STRUCT struct nd_advt { 96 uint32 reserved1 : 5, override : 1, solicited : 1, router : 1, 97 reserved2 : 24; 98 } BWL_POST_PACKED_STRUCT nd_advt; 99 } BWL_POST_PACKED_STRUCT opt; 100 } BWL_POST_PACKED_STRUCT; 101 102 /* Ipv6 Header Format */ 103 BWL_PRE_PACKED_STRUCT struct ipv6_hdr { 104 uint8 priority : 4, version : 4; 105 uint8 flow_lbl[3]; 106 uint16 payload_len; 107 uint8 nexthdr; 108 uint8 hop_limit; 109 struct ipv6_addr saddr; 110 struct ipv6_addr daddr; 111 } BWL_POST_PACKED_STRUCT; 112 113 /* Neighbor Advertisement/Solicitation Packet Structure */ 114 BWL_PRE_PACKED_STRUCT struct bcm_nd_msg { 115 struct icmp6_hdr icmph; 116 struct ipv6_addr target; 117 } BWL_POST_PACKED_STRUCT; 118 119 /* Neighibor Solicitation/Advertisement Optional Structure */ 120 BWL_PRE_PACKED_STRUCT struct nd_msg_opt { 121 uint8 type; 122 uint8 len; 123 uint8 mac_addr[ETHER_ADDR_LEN]; 124 } BWL_POST_PACKED_STRUCT; 125 126 /* Ipv6 Fragmentation Header */ 127 BWL_PRE_PACKED_STRUCT struct ipv6_frag { 128 uint8 nexthdr; 129 uint8 reserved; 130 uint16 frag_offset; 131 uint32 ident; 132 } BWL_POST_PACKED_STRUCT; 133 134 /* This marks the end of a packed structure section. */ 135 #include <packed_section_end.h> 136 137 static const struct ipv6_addr all_node_ipv6_maddr = { 138 {0xff, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}; 139 140 #define IPV6_ISMULTI(a) (a[0] == 0xff) 141 142 #define IPV6_MCAST_TO_ETHER_MCAST(ipv6, ether) \ 143 { \ 144 ether[0] = 0x33; \ 145 ether[1] = 0x33; \ 146 ether[2] = ipv6[12]; \ 147 ether[3] = ipv6[13]; \ 148 ether[4] = ipv6[14]; \ 149 ether[5] = ipv6[15]; \ 150 } 151 152 #endif /* !defined(_bcmipv6_h_) */ 153