wifi: update bcm driver to 101.10.240 to support android r [1/2]
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_dhd-driver.git] / bcmdhd.101.10.240.x / include / bcmipv6.h
CommitLineData
1b4a7c03
LJ
1/*
2 * Fundamental constants relating to Neighbor Discovery Protocol
3 *
4 * Copyright (C) 2020, 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 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 *
21 * <<Broadcom-WL-IPTag/Dual:>>
22 */
23
24#ifndef _bcmipv6_h_
25#define _bcmipv6_h_
26
27#ifndef _TYPEDEFS_H_
28#include <typedefs.h>
29#endif
30
31/* This marks the start of a packed structure section. */
32#include <packed_section_start.h>
33
34/* Extension headers */
35#define IPV6_EXT_HOP 0
36#define IPV6_EXT_ROUTE 43
37#define IPV6_EXT_FRAG 44
38#define IPV6_EXT_DEST 60
39#define IPV6_EXT_ESEC 50
40#define IPV6_EXT_AUTH 51
41
42/* Minimum size (extension header "word" length) */
43#define IPV6_EXT_WORD 8
44
45/* Offsets for most extension headers */
46#define IPV6_EXT_NEXTHDR 0
47#define IPV6_EXT_HDRLEN 1
48
49/* Constants specific to fragmentation header */
50#define IPV6_FRAG_MORE_MASK 0x0001
51#define IPV6_FRAG_MORE_SHIFT 0
52#define IPV6_FRAG_OFFS_MASK 0xfff8
53#define IPV6_FRAG_OFFS_SHIFT 3
54
55/* For icmpv6 */
56#define ICMPV6_HEADER_TYPE 0x3A
57#define ICMPV6_PKT_TYPE_RA 134
58#define ICMPV6_PKT_TYPE_NS 135
59#define ICMPV6_PKT_TYPE_NA 136
60
61#define ICMPV6_ND_OPT_TYPE_TARGET_MAC 2
62#define ICMPV6_ND_OPT_TYPE_SRC_MAC 1
63
64#define ICMPV6_ND_OPT_LEN_LINKADDR 1
65
66#define ICMPV6_ND_OPT_LEN_LINKADDR 1
67
68#define IPV6_VERSION 6
69#define IPV6_HOP_LIMIT 255
70
71#define IPV6_ADDR_NULL(a) ((a[0] | a[1] | a[2] | a[3] | a[4] | \
72 a[5] | a[6] | a[7] | a[8] | a[9] | \
73 a[10] | a[11] | a[12] | a[13] | \
74 a[14] | a[15]) == 0)
75
76#define IPV6_ADDR_LOCAL(a) (((a[0] == 0xfe) && (a[1] & 0x80))? TRUE: FALSE)
77
78/* IPV6 address */
79BWL_PRE_PACKED_STRUCT struct ipv6_addr {
80 uint8 addr[16];
81} BWL_POST_PACKED_STRUCT;
82
83/* use masks, htonl instead of bit fileds */
84
85/* ICMPV6 Header */
86BWL_PRE_PACKED_STRUCT struct icmp6_hdr {
87 uint8 icmp6_type;
88 uint8 icmp6_code;
89 uint16 icmp6_cksum;
90 BWL_PRE_PACKED_STRUCT union {
91 uint32 reserved;
92 BWL_PRE_PACKED_STRUCT struct nd_advt {
93 uint32 reserved1:5,
94 override:1,
95 solicited:1,
96 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 */
103BWL_PRE_PACKED_STRUCT struct ipv6_hdr {
104 uint8 priority:4,
105 version:4;
106 uint8 flow_lbl[3];
107 uint16 payload_len;
108 uint8 nexthdr;
109 uint8 hop_limit;
110 struct ipv6_addr saddr;
111 struct ipv6_addr daddr;
112} BWL_POST_PACKED_STRUCT;
113
114/* Neighbor Advertisement/Solicitation Packet Structure */
115BWL_PRE_PACKED_STRUCT struct bcm_nd_msg {
116 struct icmp6_hdr icmph;
117 struct ipv6_addr target;
118} BWL_POST_PACKED_STRUCT;
119
120/* Neighibor Solicitation/Advertisement Optional Structure */
121BWL_PRE_PACKED_STRUCT struct nd_msg_opt {
122 uint8 type;
123 uint8 len;
124 uint8 mac_addr[ETHER_ADDR_LEN];
125} BWL_POST_PACKED_STRUCT;
126
127/* Ipv6 Fragmentation Header */
128BWL_PRE_PACKED_STRUCT struct ipv6_frag {
129 uint8 nexthdr;
130 uint8 reserved;
131 uint16 frag_offset;
132 uint32 ident;
133} BWL_POST_PACKED_STRUCT;
134
135/* This marks the end of a packed structure section. */
136#include <packed_section_end.h>
137
138static const struct ipv6_addr all_node_ipv6_maddr = {
139 { 0xff, 0x2, 0, 0,
140 0, 0, 0, 0,
141 0, 0, 0, 0,
142 0, 0, 0, 1
143 }};
144
145#define IPV6_ISMULTI(a) (a[0] == 0xff)
146
147#define IPV6_MCAST_TO_ETHER_MCAST(ipv6, ether) \
148{ \
149 ether[0] = 0x33; \
150 ether[1] = 0x33; \
151 ether[2] = ipv6[12]; \
152 ether[3] = ipv6[13]; \
153 ether[4] = ipv6[14]; \
154 ether[5] = ipv6[15]; \
155}
156
157#endif /* !defined(_bcmipv6_h_) */