• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Fundamental constants relating to Neighbor Discovery Protocol
3  *
4  * Copyright (C) 1999-2017, Broadcom Corporation
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 of
16  * the license of that module.  An independent module is a module which is not
17  * 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
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)    ((a[0] | a[1] | a[2] | a[3] | a[4] | \
78                              a[5] | a[6] | a[7] | a[8] | a[9] | \
79                              a[10] | a[11] | a[12] | a[13] | \
80                              a[14] | a[15]) == 0)
81 
82 #define IPV6_ADDR_LOCAL(a)    (((a[0] == 0xfe) && (a[1] & 0x80))? TRUE: FALSE)
83 
84 /* IPV6 address */
85 BWL_PRE_PACKED_STRUCT struct ipv6_addr {
86         uint8        addr[16];
87 } BWL_POST_PACKED_STRUCT;
88 
89 
90 /* ICMPV6 Header */
91 BWL_PRE_PACKED_STRUCT struct icmp6_hdr {
92     uint8    icmp6_type;
93     uint8    icmp6_code;
94     uint16    icmp6_cksum;
95     BWL_PRE_PACKED_STRUCT union {
96         uint32 reserved;
97         BWL_PRE_PACKED_STRUCT struct nd_advt {
98             uint32    reserved1:5,
99                 override:1,
100                 solicited:1,
101                 router:1,
102                 reserved2:24;
103         } BWL_POST_PACKED_STRUCT nd_advt;
104     } BWL_POST_PACKED_STRUCT opt;
105 } BWL_POST_PACKED_STRUCT;
106 
107 /* Ipv6 Header Format */
108 BWL_PRE_PACKED_STRUCT struct ipv6_hdr {
109     uint8    priority:4,
110         version:4;
111     uint8    flow_lbl[3];
112     uint16    payload_len;
113     uint8    nexthdr;
114     uint8     hop_limit;
115     struct    ipv6_addr    saddr;
116     struct    ipv6_addr    daddr;
117 } BWL_POST_PACKED_STRUCT;
118 
119 /* Neighbor Advertisement/Solicitation Packet Structure */
120 BWL_PRE_PACKED_STRUCT struct bcm_nd_msg {
121     struct    icmp6_hdr    icmph;
122     struct    ipv6_addr    target;
123 } BWL_POST_PACKED_STRUCT;
124 
125 
126 /* Neighibor Solicitation/Advertisement Optional Structure */
127 BWL_PRE_PACKED_STRUCT struct nd_msg_opt {
128     uint8 type;
129     uint8 len;
130     uint8 mac_addr[ETHER_ADDR_LEN];
131 } BWL_POST_PACKED_STRUCT;
132 
133 /* Ipv6 Fragmentation Header */
134 BWL_PRE_PACKED_STRUCT struct ipv6_frag {
135     uint8    nexthdr;
136     uint8    reserved;
137     uint16    frag_offset;
138     uint32    ident;
139 } BWL_POST_PACKED_STRUCT;
140 
141 /* This marks the end of a packed structure section. */
142 #include <packed_section_end.h>
143 
144 static const struct ipv6_addr all_node_ipv6_maddr = {
145                                     { 0xff, 0x2, 0, 0,
146                                     0, 0, 0, 0,
147                                     0, 0, 0, 0,
148                                     0, 0, 0, 1
149                                     }};
150 
151 #define IPV6_ISMULTI(a) (a[0] == 0xff)
152 
153 #define IPV6_MCAST_TO_ETHER_MCAST(ipv6, ether) \
154 { \
155     ether[0] = 0x33; \
156     ether[1] = 0x33; \
157     ether[2] = ipv6[12]; \
158     ether[3] = ipv6[13]; \
159     ether[4] = ipv6[14]; \
160     ether[5] = ipv6[15]; \
161 }
162 
163 #endif    /* !defined(_bcmipv6_h_) */
164